Spring整合RabbitMQ 一直收到重复消息怎么处理
展开全部
监听的代码改成这样试试
public class RabbitMqListener implements MessageListener {
@Override
public void onMessage(Message message) {
try {
String str = new String(message.getBody());
// TODO 接受消息
System.out.println(message.getMessageProperties().getMessageId());
System.out.println("Recived msg:" + str);
} catch (Exception e) {
// TODO: handle exception
}
}
}
public class RabbitMqListener implements MessageListener {
@Override
public void onMessage(Message message) {
try {
String str = new String(message.getBody());
// TODO 接受消息
System.out.println(message.getMessageProperties().getMessageId());
System.out.println("Recived msg:" + str);
} catch (Exception e) {
// TODO: handle exception
}
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询