修改autodelete ,交换器有此属性,消息队列也有,设为true表示临时,不会持久化,设为false,服务器宕机也能保存到磁盘
-
@Component
-
@RabbitListener(
-
bindings = @QueueBinding(
-
value = @Queue(value = "${mq.config.queue.sms}",autoDelete = "false"),
-
exchange = @Exchange(value = "${mq.config.exchange}",type = ExchangeTypes.FANOUT)
-
)
-
)
-
public class Accepter {
-
/**接收消息的方法
-
* 注解的监听队列名称,可以是数组
-
*/
-
/* @RabbitListener(queues={"hello-queue"})
-
public void process(String msg){
-
System.out.println("这是接收到的消:{}"+msg);
-
}*/
-
@RabbitHandler
-
public void process(String msg){
-
System.out.println("这是接收到的消息sms:{}"+msg);
-
}
-
}