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?
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? :