Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dead letter exchange RabbitMQ dropping messages

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?

like image 848
Fabrizio Sestito Avatar asked Nov 29 '12 10:11

Fabrizio Sestito


1 Answers

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.

like image 110
kzhen Avatar answered Oct 09 '22 20:10

kzhen