Dead letter exchange RabbitMQ dropping messages

可紊 提交于 2019-12-07 01:26:38

问题


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:


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.



来源:https://stackoverflow.com/questions/13623947/dead-letter-exchange-rabbitmq-dropping-messages

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!