1

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?

Artem
  • 7,275
  • 15
  • 57
  • 97

1 Answers1

3

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.

pinepain
  • 12,453
  • 3
  • 60
  • 65
  • Yes, but if I have 3 queues can I setup the rule that dead-letter message moves from queue2 to queue3 only if it was rejected? – Artem Nov 13 '14 at 14:46
  • DLX works if message was rejected or TTL or length limit reached. So if you don't use TTL and don't have queue length set then yes, you'll get what you want. – pinepain Nov 13 '14 at 15:29
  • If messages already moved from queue1 to queue2 with dead-letter by TTL, does it mean that there are no way to move ONLY ones which were read and rejected among those to move to queue3? – Artem Nov 13 '14 at 15:40
  • I would say no. Without consuming messages it doesn't looks possible. But there are exchange to exchange bindings, so maybe they can help you with that. While I'm not sure about them, try to play with headers exchanges and e2e binginds. Or better ask this question in [official RabbitMQ user group](https://groups.google.com/forum/#!forum/rabbitmq-users). Anyway, it would be nice to get feedback with solution you choose. – pinepain Nov 13 '14 at 16:59
  • I got response to my message from RabbitMQ users group: https://groups.google.com/forum/#!topic/rabbitmq-users/gR-PlZWyYMk so they confirmed that message will not move from queue2 to queue3 automatically until deal-lettered again. Can you please update your answer so I can accept it? – Artem Nov 16 '14 at 18:22
  • Thanks for stay in touch! I've added reference to discussion and add quote from Simon's answer. – pinepain Nov 16 '14 at 22:58