AutorecoveringConnection feature with unnamed queue

95 views
Skip to first unread message

Alf

unread,
Feb 5, 2021, 3:26:35 AM2/5/21
to rabbitmq-users
Hello,

I am facing a strange issue with AutomaticRecovery feature on Java with the following rabbitmq client.
    <dependency>
      <groupId>com.rabbitmq</groupId>
      <artifactId>amqp-client</artifactId>
      <version>5.10.0</version>
    </dependency>

If I use predefined named queue, everything is working fine, but if I let rabbitMQ server returning a queue name by passing an empty string to queueDeclare, then the recovered queue is not having the same name. The result is that my messages are not send to the new queue but the old one. I didn't see any hint on that topic on the rabbitmq documentation, so I am wondering if it is a bug or not.
I just wanted to let the rmq server handle the uniqueness of the queue name instead of generating one randomly.

Any hint ?

AMQChannel(amqp://mb...@127.0.0.1:5672/,10)
2021-02-04 22:46:36.572 [AMQP Connection 127.0.0.1:5672] DEBUG AutorecoveringConnection - Channel AMQChannel(amqp://mb...@127.0.0.1:5672/,10) has recovered
2021-02-04 22:46:36.573 [AMQP Connection 127.0.0.1:5672] DEBUG AutorecoveringConnection - Recovering RecordedQueue[name=amq.gen-fK8lpRqri6sKqY_OquUT4A, durable=false, autoDelete=false, exclusive=false, arguments=nullserverNamed=true, channel=AMQChannel(amqp://mb...@127.0.0.1:5672/,1)]
2021-02-04 22:46:36.967 [AMQP Connection 127.0.0.1:5672] DEBUG AutorecoveringConnection - RecordedQueue[name=amq.gen-G-9In27Xrv3ANpcmnpW88Q, durable=false, autoDelete=false, exclusive=false, arguments=nullserverNamed=true, channel=AMQChannel(amqp://mb...@127.0.0.1:5672/,1)] has recovered

M K

unread,
Feb 5, 2021, 10:52:49 AM2/5/21
to rabbitmq-users
During connection recovery, server-named queues are re-declared as, well, server-named, so their names
change. Re-registered consumers will use the new name.

For publishers, if you rely on knowing a server-named queue name, you are doing it wrong. Use a well-known name based on
a consumer identity of some kind. You can observe queue name changes using a callback as well,
AutorecoveringConnection#addQueueRecoveryListener(QueueRecoveryListener listener). However, publishers not running in the same
process won't have this option. So use well-known queue names if they are somehow important to publishers.

M K

unread,
Feb 5, 2021, 11:41:57 AM2/5/21
to rabbitmq-users
I added a note [1] on how server-named queues (and their names) are expected.
The listener was primarily added to help consumers and integration tests observe
queue names. Publishers should really publish to well known exchanges, to which
consumers set up the bindings for their queues as appropriate.

Reply all
Reply to author
Forward
Message has been deleted
0 new messages