joekarl
joekarl

Reputation: 2118

Persistent Message durability across exchange RabbitMQ

I'm a bit confused on how RabbitMQ handles persistent messages forwarded from an exchange in direct mode that are in a queue that has disconnected.

Situation is this.

       -> Exclusive Queue -> Client 1
      /
Exch - 
      \
       -> Exclusive Queue -> Client 2

Persistent messages are sent to the exchange which distributes them to the exclusive queues. Client 1 dies destroying its exclusive queue.

My question is, if there are messages on that queue, do they get lost? Or are they resent to the exchange?

Or is this a bad idea? Would it be better to have each client connect to a single queue? (this needs to have persistent messages and high throughput so not sure that that is an option...)

Upvotes: 1

Views: 1351

Answers (1)

robthewolf
robthewolf

Reputation: 7624

Persistent messages are only persistent in queues. In fact only in durable queues. What that means is if RabbitMQ itself goes down for what ever reason. If there are unconsumed persistent messages in a durable queue they will be reinstated along with the queue when RabbitMQ is restarted.

So this does not help your problem. What you want to do is make sure that the autodelete setting is set to false. You don't even need to have persistent messages to make this work. Autodelete removes the queue when there is nolonger a connected consumer. If your client dies nicely and properly removes the connection then it is also going to autodelete the queue if you have it set to true (which I believe is the default).

Setting autodelete to false will mean that the queue is always there and always receiving messages after it has been declared. So if your client dies and there are still messages in the queue they will still be there when the client is restarted.

Upvotes: 1

Related Questions