RabbitMQ 死信交换永远不会收到消息 [英] RabbitMQ dead letter exchange never getting messages

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

问题描述

我正在尝试设置我的第一个 RabbitMQ 死信交换,以下是我通过 Web 管理界面使用的步骤:

I'm trying to setup my first RabbitMQ dead letter exchange, here are the steps I'm using through the web admin interface:

  1. 使用名称dead.letter.test"创建新的 DIRECT 交换
  2. 创建新队列dead.letter.queue"
  3. 将dead.letter.queue"绑定到dead.letter.test"
  4. 创建新队列test1",将死信交换设置为dead.letter.test"
  5. 向test1"发送消息
  6. Nack (with requeue = false) "test1" 中的消息

我期望这些步骤应该通过dead.letter.test"交换将记录放入dead.letter.queue".这没有发生.

I am expecting that these steps should put a record into the "dead.letter.queue" through the "dead.letter.test" exchange. This is not happening.

我可以手动将消息放入dead.letter.test"交换中,它会显示在dead.letter.queue"中,所以我知道这很好.

I can manually put a message into the "dead.letter.test" exchange and it shows up in "dead.letter.queue" so I know that is fine.

当我查看管理 UI 时,它显示 DLX 参数已设置在队列test1"上.

When I look at the admin UI it shows that the DLX parameter is setup on the queue "test1".

我哪里错了?

推荐答案

Gentilissimo Signore 在 Twitter 上回答了我的问题.问题是,如果您的死信交换设置为 DIRECT,您必须指定死信路由键.如果您只想将所有 NACKed 消息放入死信桶以供以后调查(就像我一样),那么您的死信交换应该设置为 FANOUT.

Gentilissimo Signore was kind enough to answer my question on Twitter. The problem is that if your dead letter exchange is setup as DIRECT you must specify a dead letter routing key. If you just want all your NACKed message to go into a dead letter bucket for later investigation (as I do) then your dead letter exchange should be setup as a FANOUT.

以下是有效的更新步骤:

Here are the updated steps that work:

  1. 创建名为dead.letter.test"的新 FANOUT 交换
  2. 创建新队列dead.letter.queue"
  3. 将dead.letter.queue"绑定到dead.letter.test"
  4. 创建新队列test1",将死信交换设置为dead.letter.test"
  5. 向test1"发送消息
  6. Nack (with requeue = false) "test1" 中的消息

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

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