死信交换RabbitMQ丢弃消息 [英] Dead letter exchange RabbitMQ dropping messages

查看:361
本文介绍了死信交换RabbitMQ丢弃消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在RabbitMQ中实现dlx队列. 场景很简单 我有2个队列: 1)活着 2)已死亡(x-dead-letter-exchange:立即",x-message-ttl:5000)

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)

和绑定到1)的交换即时"

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

我尝试运行此示例: http://blog.james-carr .org/2012/03/30/rabbitmq-sending-a-message-to-consumed-consumed-later/ 但似乎消息在ttl到期后被丢弃,并且它们没有在交易所中发布,因此我的活动队列始终为空.

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.

我用Ubuntu/rabbitmq 3.0.0以及Mac OS X和Rabbitmq 2.8.7对其进行了测试

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

我想念什么吗?

推荐答案

当RabbitMQ中的消息消失"时,问题通常归结于绑定.因此,为了使您的示例正常工作,我执行了以下操作:

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

  1. 创建2个活着的,已死的队列(使用TTL和DLX)

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

创建了一个名为DIRECT类型的即时交换

Created an exchange called immediate of type DIRECT

使用路由键"dead"在交换立即"和队列活动"之间创建绑定-之所以这样,是因为消息进入死队列的路由键(如果使用默认值)交换是死信",这需要在死信交换上的绑定中进行匹配.)

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.

这篇关于死信交换RabbitMQ丢弃消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆