如果队列不存在,则队列侦听器将失败Spring-Rabbit

时间:2018-07-26 07:35:22

标签: spring-boot rabbitmq spring-rabbit spring-rabbitmq

我们正在尝试在Spring Boot应用程序中使用spring-rabbit创建消息侦听器。但是,如果队列不存在,则在接收消息期间会出现问题,应用程序将引发错误,这称为被动声明。

Channel error on connection (172.13.1.3:49352 -> 172.13.1.7:5672, vhost: '/', user: 'guest'), channel 1:
message_queue_1_1  | operation queue.declare caused a channel exception not_found: no queue 'add' in vhost '/'

我们想要的是主动声明一个队列,即,如果该队列不存在,则应在mq中声明它。

1 个答案:

答案 0 :(得分:0)

要从应用程序自动在Broker上声明AMQP对象,您确实需要将它们配置为bean,并且还具有一个特殊的AmqpAdmin bean以执行硬声明逻辑。该文档具有所有必需的说明:https://docs.spring.io/spring-amqp/docs/2.0.4.RELEASE/reference/html/_reference.html#broker-configuration

相关问题