Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RabbitMQ, dead letters exchanges -> Can't route message to the default exchange?

With the RabbitMQ Admin (v3), I tried to create a queue that will send dead letter messages to the default exchange, with a routing key "MyErrorRoutingKey" on which is binded an error queue. So in the administration interface, I left the "dead letter exchange" blank.

I just wonder if it is normal to have the following message when trying to create the queue:

406 PRECONDITION_FAILED - invalid arg 'x-dead-letter-routing-key' for queue 'MyQueue' in vhost '/': routing_key_but_no_dlx_defined

It seems possible to route dead letter messages to the default exchange because further in the documentation it is said:

It is possible to form a cycle of dead-letter queues. For instance, this can happen when a queue dead-letters messages to the default exchange without specifiying a dead-letter routing key. Messages in such cycles (i.e. messages that reach the same queue twice) will be dropped.

So how I am supposed to route messages to the default exchange? Unlike the "cyclic useless dead-letter" described above, I want to be able to specify the routing key so that my messages are not lost.

like image 829
Sebastien Lorber Avatar asked Jan 03 '13 15:01

Sebastien Lorber


2 Answers

Old question but no-one seems to have answered so I'll give it a shot.

I was having trouble with the exact same error using the web UI but I was able to get around it by setting the "x-dead-letter-exchange" and "x-dead-letter-routing-key" manually as custom arguments instead of using the provided fields.

enter image description here

like image 161
kipple Avatar answered Sep 18 '22 22:09

kipple


Sounds to me like routing_key_but_no_dlx_defined says that you should not define a dead-letter-routing-key if you are not defining a dead-letter-exchange, which sort of makes sense too.

I'm not sure exactly what you're trying to do with the default exchange, but that too has a name so maybe you can just set the dead-letter-exchange also...

Regarding your last quote from the docs it means that if you have setup a cycle using dead-letter-exchanged, i.e:

QUEUE-A > DEAD-LETTER-QUEUE > QUEUE-A

...RabbitMQ will drop the message as it comes back to QUEUE-A if it leaves the DEAD-LETTER-QUEUE because of a timeout. If such a delayed retry is what you want you'll have to manually queue your message to the DEAD-LETTER-QUEUE currently, but there's a indication that RabbitMQ may let you have such cycles later on (http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/2013-April/026489.html).

like image 37
Magge Avatar answered Sep 20 '22 22:09

Magge