Commit 108546ce authored by 赵啸非's avatar 赵啸非

添加告警统计信息

parent 79cf29e2
......@@ -54,6 +54,9 @@ public class RabbitConfig {
message.getMessageProperties().setContentType("application/json");
return message;
});
container.setDefaultRequeueRejected(false);
//设置异常处理
//container.setErrorHandler(rabbitLoggingErrorHandler);
// 并发消费,不使用
......
......@@ -16,11 +16,18 @@ import org.springframework.stereotype.Service;
public class SimpleDynamicListener implements ChannelAwareMessageListener {
@Override
public void onMessage(Message message, Channel channel) throws Exception {
String queue = message.getMessageProperties().getConsumerQueue();
byte[] body = message.getBody();
log.info("接收到:" + queue + ",消息内容为:" + new String(body));
channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
log.info(queue + "队列消息消费成功");
public void onMessage(Message message, Channel channel) {
try {
if (message.equals("exception")) {
log.info("rabbitmq ecception!");
}
String queue = message.getMessageProperties().getConsumerQueue();
byte[] body = message.getBody();
log.info("接收到:" + queue + ",消息内容为:" + new String(body));
channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
log.info(queue + "队列消息消费成功");
} catch (Exception e) {
log.error("接收消息异常");
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment