RabbitMQ: Can dead-lettered message die again?

467 Views Asked by At

We have implemented delayed message processing with 2 queues and x-dead-letter-exchange/x-message-ttl where after message timeout in queue1 it will go to queue2.

Now is it possible to setup RabbitMQ so that if during processing messages from queue2 we reject it as "dead-letter" then it will automatically go to queue3? My concern is that messages in queue2 are already marked as "dead", is there a way to distinguish the ones which are dead because they were rejected and automatically put only those to queue3?

1

There are 1 best solutions below

6
On BEST ANSWER

Yes it is possible that message dead-lettered multiple time.

To see reason(s) why message was dead-lettered, look into x-death header, which is array sorted most-recent-first, so latest reason why message was dead-lettered is first.

For more details look into Dead-Lettered Messages section in Dead Letter Exchanges manual.

UPD:

Discussed in RabbitMQ official user group about Is it possible to to move dead-lettered message only if it was rejected? :

...

My concern is the following: since the messaged are already dead-lettered by TTL is there any way to move them from Queue2 to Queue3 only if they are rejected?

To strictly answer your question, no: you can't choose on which events to dead-letter.

However, I think what you're really asking is "won't all messages from queue2 immediately dead-letter to queue3 since they have already dead-lettered once?" And the answer to that is no; once a message has been dead-lettered to queue2 it is then a free agent and will only be dead-lettered again if it does something dead-letterable again.