RabbitMQ difference between exclusive and auto-delete?

后端 未结 2 1654
时光说笑
时光说笑 2021-01-30 06:37

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

2条回答
  •  鱼传尺愫
    2021-01-30 07:30

    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.

提交回复
热议问题