Jakub Kubrynski
Jakub Kubrynski

Reputation: 14149

operation queue.declare caused a channel exception not_found: no queue for spring amqp

I've two applications using the same spring-amqp and spring-cloud-stream configuration. However, when one of the rabbitmq cluster node goes down, one application is redeclaring anonymous queues while the second one fails. The only difference I found in the logs is additional boolean value in the amqqueue log. The whole declaration during the application startup works as a charm. The only issue is when the rabbitmq node on which the queue is registered is shutdown.

== WORKING APPLICATION ==

spring: Auto-declaring a non-durable, auto-delete, or exclusive Queue (myQueueName.anonymous.A6dm37UlRsisaftuN8SwkQ) durable:false, auto-delete:true, exclusive:true. It will be redeclared if the broker stops and is restarted while the connection factory is alive, but all messages will be lost.

rabbit: 2019-08-13 00:27:02.636 [debug] <0.1241.0> Supervisor {<0.1241.0>,rabbit_amqqueue_sup} started rabbit_prequeue:start_link({amqqueue,{resource,<<"/">>,queue,<<"myQueueName.anonymous.A6dm37UlRsisaftuN8SwkQ">>},false,...}, declare, <0.1240.0>) at pid <0.1242.0>

== FAILING APPLICATION ==

spring: Auto-declaring a non-durable, auto-delete, or exclusive Queue (myQueueName.anonymous.-6He5tcQSB2Bk17EIiay3g) durable:false, auto-delete:true, exclusive:true. It will be redeclared if the broker stops and is restarted while the connection factory is alive, but all messages will be lost.

rabbit: 2019-08-13 00:24:07.097 [debug] <0.2922.0> Supervisor {<0.2922.0>,rabbit_amqqueue_sup} started rabbit_prequeue:start_link({amqqueue,{resource,<<"/">>,queue,<<"myQueueName.anonymous.-6He5tcQSB2Bk17EIiay3g">>},false,true,...}, declare, <0.2921.0>) at pid <0.2923.0>

rabbit: operation queue.declare caused a channel exception not_found: no queue 'myQueueName.anonymous.-6He5tcQSB2Bk17EIiay3g' in vhost '/'

Upvotes: 6

Views: 24509

Answers (2)

DenisKolodin
DenisKolodin

Reputation: 15071

Another reason for this issue if you set passive flag for queue_declare method:

https://www.rabbitmq.com/amqp-0-9-1-reference.html#queue.declare.passive

It expects that someone already created a queue. Unset the flag or create a queue with other component of your app.

Upvotes: 4

Jakub Kubrynski
Jakub Kubrynski

Reputation: 14149

Finally I've realized the difference between those two applications is that the first one is the consumer as well as the producer. If the application is just a consumer and it does not contain producer definition, the exchange redeclaration handled by spring during the broker restart fails (even if the exchange is properly registered on the node before this operation). Setting declareExchange=false in the consumer properties resolved the issue.

Upvotes: 1

Related Questions