user3412955
user3412955

Reputation: 13

RabbitMQ Exclusive Queue Lost Messages

For a consumer, when declaring a Queue to be 'exclusive', the Queue will be deleted when consumer disconnects per the documentation.

Assuming there are messages in the Queue awaiting processing and the consumer goes offline, all messages on this 'exclusive' Queue will be lost when Queue is removed.

Are there any strategies or ways to keep a Queue 'exclusive' but preserve the messages in the Queue/Broker so nothing is lost?

Thanks in advance.

Upvotes: 1

Views: 955

Answers (1)

Ken Chan
Ken Chan

Reputation: 90447

Exclusive queue will be deleted when the channel created it disconnects.

What you probably want is exclusive consumer which can be done by setting exclusive parameter to true when consume from a queue. Exclusive consumer ensures that only one consumer can consume this queue .It excludes all other consumers from the queue once it is consumed.

In summary , to make a queue exclusive to one consumer and persist the messages in this queue, you should :

  • Declare the queue to be durable
  • When producer publishes message , the message 's delivery mode should set to persistent
  • Use exclusive consumer

Upvotes: 2

Related Questions