7

I'm trying to implement a dlx queue in RabbitMQ. The scenario is quite easy I have 2 queues: 1) alive 2) dead (x-dead-letter-exchange: "immediate", x-message-ttl: 5000)

and an exchange "immediate" that is bound to 1) alive

I tried to run this example: http://blog.james-carr.org/2012/03/30/rabbitmq-sending-a-message-to-be-consumed-later/ but it seems that the messages are dropped after the ttl expires and they dont get published on the exchange, so my alive queue is always empty.

I also tried to create the queues by hand in the management console and I get the same behaviour.

I tested it with Ubuntu/rabbitmq 3.0.0 and with Mac OS X and rabbitmq 2.8.7

Am I missing something?

1 Answers1

8

When messages 'disappear' in RabbitMQ the problem is usually down to the bindings. So, to get your example working I did the following:

  1. Created 2 queues, alive, dead (with the TTL and DLX)

  2. Created an exchange called immediate of type DIRECT

  3. Created a binding between the exchange "immediate" and the queue "alive" with a routing key "dead" - the reason for this is because, the routing key for messages into the dead queue (if using the default exchange is 'dead' this needs to match in the binding on the dead letter exchange).

The important part here is in the binding between the immediate exchange and the alive queue.

To test I published a message into the dead queue, I can see it appear in the dead queue briefly then appear in the alive queue.

kzhen
  • 3,020
  • 19
  • 21
  • I did a spike and hit a few showstoppers: 1. Messages are only DLQ:en when at the top of the Q (http://www.rabbitmq.com/ttl.html – Caveats section) This means that if I first set msg 1 to expire in 4 hours and msg2 to expire in 1 hours msg2 will only expire after msg1 has expired. 2. The TTL for the message is kept by Rabbit so lets say you use a short timeout of 10 s. If the consumer hasn’t been able to consume the message withing 10 seconds after it expired (due to a backlog) it will be discarded and lost The above has been verified with Rabbit 3.0.1. Do you guys see any workarounds? – Andreas Öhlund Jan 15 '13 at 15:00
  • 2
    @AndreasÖhlund,try to design by using "per queue TTL", not "per message TTL", if possible. – Ahmet Akyol May 11 '13 at 12:20