0

Really confused here...

Have a queue with dead letter props set...

var amqp = require('amqp'),
    conn = amqp.createConnection();

var key = "batch.delay." + (new Date().getTime()).toString();
var options = {
  arguments: {
    "x-dead-letter-exchange": "immediate",
    "x-message-ttl": 30000,
    "x-expires": 40000,
    "x-dead-letter-routing-key": 'hit.api'
  }
};

conn.queue(key, options);

and defining the actual exchange...

conn.exchange('immediate', {
  durable: true,
  autoDelete: false,
  type: 'direct'
}, function (exchange) {
  // other thing...
});

The problem is that all traffic is going through the default exchange and not the dead letter exchange. The ttl props are being honored but not the exchange name. That is seen here...

enter image description here

Ideas?

Edit:

below you can see the queues created that should funnel into the DLX once they expire.

enter image description here

4

3 回答 3

0

您上面的示例设置了一个带有路由键的 DLX,这很好,但是您需要指定一个接受该路由键的死信队列。

如果您不需要路由密钥,我建议您使用扇出交换。我在这里发布了如何做到这一点的答案:

https://stackoverflow.com/a/21864158/1173800

于 2015-03-06T15:50:15.357 回答
0

问题是您试图在每条消息的基础上设置 x-dead-letter-exchange。在整个队列上设置 DLX。您可以看到您的队列上没有 DLX,如果有,它将有一个如下图所示的 DLX 图标。

在此处输入图像描述

然后,您将 x-dead-letter-routing-key 添加到各个消息中。

x-expire 也是队列级别设置与消息级别设置。

于 2015-03-06T16:31:11.580 回答
0

好的,所以..是这样的:

  • 创建一个对 DLX 过期的队列?查看。
  • 创建 DLX?查看。
  • 将数据推送到过期的队列?没有。

这是一个范围问题......我认为我正在循环数据,这些数据将发布到即将到期的队列,但数据始终是一个空数组,因此没有发布任何内容。

一旦我弄清楚这一点,队列就会填满数据,过期到 DLX,绑定到 DLX 的队列会获取数据。

非常感谢@jhilden 与我讨论。

于 2015-03-06T17:05:20.837 回答