This commit is contained in:
雷欧(林平凡)
2024-12-02 09:59:56 +08:00
parent 2d8e343e4f
commit ae3e2149c0
3 changed files with 9 additions and 10 deletions

View File

@@ -35,7 +35,7 @@ public class MessageConsumerService implements RocketMQListener<JSONObject> {
// 处理消息
try {
rateLimiter.acquire(); // 请求许可。如果超过速率,则此方法会阻塞
logger.info("消费到消息:{}", jsonObject);
//logger.info("消费到消息:{}", jsonObject);
String body = jsonObject.getString("body");
byte[] decodedBody = Base64.getDecoder().decode(body);
String decodedBodyStr = new String(decodedBody, StandardCharsets.UTF_8);
@@ -51,13 +51,12 @@ public class MessageConsumerService implements RocketMQListener<JSONObject> {
// TODO: 如果需要处理错误,您可以在这里添加逻辑
throw new RuntimeException("消息发送失败: " + responseStr);
}
logger.info("消息成功发送并得到响应:{}", response);
//logger.info("消息成功发送并得到响应:{}", response);
} else {
throw new RuntimeException("消息发送失败,没有收到响应");
}
} catch (Exception e) {
logger.error("处理消息时发生错误", e);
//logger.error("处理消息时发生错误", e);
throw e; // 重抛异常使得 RocketMQ 可以捕获到这个异常
}