phprabbitmqphp-amqplib

RabbitMQ weird behavior on dead letter queue for messages from exchanges


I am using the amqp lib for php as rabbitmq client an we want to reject a message from a queue called "test"

To not get this message lost we defined the deadletter queue called "test.deadletter".

If we directly add a message to the queue "test" (via webinterface) and reject this via the basic.reject method from the amqplib client, the message gets correctly moved to the deadletter queue.

But if we use some exchange (with routing key) to get the message into the test queue and we then try to reject this, the message gets simply lost. Its not in the test queue anymore but also not in the test.deadletter queue.

The messages are the same and the two needed parameters for the basic.reject method were in both tries the same. There is no difference, just the fact, that the message came one time from an exchange and the other time from some direct insert.

Is this a kind of a bug or an expected behavior? What i am missing?

Best regards


Solution

  • Dead letter exchanges (DLXs) are normal exchanges. If your message is unroutable (due to the routing key, for instance) or if there are no queues bound to the dead-letter exchange, RabbitMQ will drop the message.

    I suspect test.deadletter is not bound to the dead-letter exchange using the same routing key as what is used to publish the message.