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

Roy Kolak
  • 605
  • 1
  • 6
  • 18

3 Answers3

0

Your example above sets up a DLX with a routing key, which is fine, but you need to then specify a dead-letter queue that accepts that routing key.

If you don't need the routing key I would suggest going with a fanout exchange. I posted an answer for how to do that here:

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

Community
  • 1
  • 1
jhilden
  • 12,207
  • 5
  • 53
  • 76
  • Didn't include that in the explanation because I have queues bound to the DLX and if I drop a message w/ a routing key in the DLX (via the management interface), the proper queue picks it up. The issue is that when the `batch.delay` queues expire, they are getting dropped in the default exchange and not the exchange specified in `x-dead-letter-exchange` argument. I feel like I'm missing a piece of the picture, am I misinterpreting how DLX are supposed to work? – Roy Kolak Mar 06 '15 at 16:22
  • @RoyKolak, checkout my newer answer, I was slightly mistaken about the root issue. – jhilden Mar 06 '15 at 16:31
0

The issue is that you're trying to set the x-dead-letter-exchange on a per message basis. a DLX is setup on an entire queue. You can see that your queue does not have a DLX on it, if it did it would have a DLX icon like the picture below.

enter image description here

You then add the x-dead-letter-routing-key to the individual messages.

x-expire is also a queue level setting vs a message level setting.

jhilden
  • 12,207
  • 5
  • 53
  • 76
  • I can verify that my `batch.delay` queue has the DLX, TTL, etc... props on it in the management console. But I noticed that during it's short lifespan, no data is published to it. I'm thinking that might be the real issue because when `batch.delay` expires, it would make sense that no traffic would be driven to the DLX. – Roy Kolak Mar 06 '15 at 16:40
  • I've never used batch.delay before and I'm not seeing it in the rabbit documentation. Do you have a link for that? – jhilden Mar 06 '15 at 16:49
  • batch.delay is just what I am naming my queues that should funnel into the deadletter exchange. I've updated my question to include a shot of these queues. – Roy Kolak Mar 06 '15 at 16:55
0

Okay, so.. it was this:

  • Creating a queue that expires to a DLX? Check.
  • Creating the DLX? Check.
  • Pushing data to the queue that expires? Nope.

It was a scoping issue... I thought that I was looping over data that would publish to the queue that was expiring, but the data was always an empty array so nothing was ever published.

Once I figured this out, the queues would fill with data, expire to the DLX, and queues bound to the DLX would pick up the data.

Big thanks to @jhilden for talking it out w/ me.

Roy Kolak
  • 605
  • 1
  • 6
  • 18