The "RabbitMQ in Action" book on page 19 gives these descriptions of exclusive and auto-delete:
exclusive - When set to true, your queue becomes private and can only be consumed by your app. This is useful when you need to limit a queue to only one consumer.
auto-delete - The queue is automatically deleted when the last consumer unsubscribes. If you need a temporary queue used only by one consumer, combine auto-delete with exclusive. When the consumer disconnects, the queue will be removed.
But as far as I can see when using exclusive, auto-delete is redundant. Only exclusive is needed. The RabbitMQ tutorial seems to say that is the case
...once we disconnect the consumer the queue should be deleted. There's an exclusive flag for that:
result = channel.queue_declare(exclusive=True)
There is no mention in that tutorial about auto-delete and sudo rabbitmqctl list_bindings
seems to indicate that the queue is in fact deleted after the receiver goes away.
An auto-delete queue will be deleted when its last consumer is cancelled (e.g. using the basic. cancel in AMQP 0-9-1) or gone (closed channel or connection, or lost TCP connection with the server). If a queue never had any consumers, for instance, when all consumption happens using the basic.
you are telling RabbitMQ to automatically acknowledge the message when it is consumed. acknowledging a message tells RabbitMQ that it has been taken care of and RabbitMQ can delete it now. set autoAck to false if you want to manually acknowledge the message after you are done processing it.
java - RabbitMQ Exchange and Queue are not created automatically - Stack Overflow. Stack Overflow for Teams – Start collaborating and sharing organizational knowledge.
A queue can be deleted from the RabbitMQ Management Interface. Enter the queue tab and go to the bottom of the page. You will find a dropdown "Delete / Purge". Press Delete to the left to delete the queue.
Well, it is true that exclusive
queues will auto-delete when the consumer disconnects (see the documentation pasted below). However, there are cases when you want queues to be non-exclusive, yet still auto-delete (for example, if I want to add another consumer).
exclusive
Exclusive queues may only be accessed by the current connection, and are deleted when that connection closes. Passive declaration of an exclusive queue by other connections are not allowed.
auto-delete
If set, the queue is deleted when all consumers have finished using it. The last consumer can be cancelled either explicitly or because its channel is closed. If there was no consumer ever on the queue, it won't be deleted. Applications can explicitly delete auto-delete queues using the Delete method as normal.
Personally, I prefer to use neither of these parameters, instead opting for the RabbitMQ queue expiration parameter, which is better if I have a consumer disconnect and then re-connect immediately (or a short time) later; messages are not lost in this case. But, of course it all depends upon your application and requirements.
In contrast to what theMayer described, my testing showed that there is a difference in behavior when auto-delete is toggled while exclusive is set to true.
If auto-delete is set to false, the queue is indeed tied to the connection and will disappear when the connection is terminated.
If auto-delete is set to true, the queue will be deleted after the last consumer is cancelled.
There is a difference between a connection and a consumer. You can be connected, but not consuming a given queue. If you need the queue's lifecycle to be tied to your connection rather than to whether or not you're actively consuming it, set auto-delete to false in conjunction with exclusive=true.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With