1
This commit is contained in:
@@ -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 可以捕获到这个异常
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user