Skip to content

[Messenger] SF 4.3 AMQP publish with delay invalid x-dead-letter-routing-key #31241

@raress96

Description

@raress96

Symfony version(s) affected: 4.3

Description
When publish a message to a queue A with a routing key A, if the message handling fails, the message will be retried 3 times by default and also a DelayStamp will be added to the envelope. So because the DelayStamp was added, the message will be published using the publishWithDelay of the AmqpExt\Connection class. That function will also call the setupDelay function, which will setup a delay queue, by default name delay_queue_1000. This delay queue will have the argument x-dead-letter-routing-key to the routing key of the message (A in this case), so after the message is released from this queue it can be re-published with the correct routing key.

However, a problem happens if a message is published to lets say a queue B with routing key B. If the handling of this message also fails, the DelayStamp will also be added to the envelope, so a the delay queue will again be setup. However, since by default the same queue name delay_queue_1000will be used, and that queue already had the argumentx-dead-letter-routing-key set to the routing key A, then the same argument can not be set to the routing key B`.

How to reproduce
Have two messages published with different routing keys (may also need to be published to different transports). When running the consume command for the first message, the handling should fail so the message should be retried 3 times. Run the consume command for the second message, which handling should also fail. Notice that an error with the message Server channel error: 406, message: PRECONDITION_FAILED - inequivalent arg 'x-dead-letter-routing-key' for queue 'delay_queue_1000' will appear in the console.

Possible Solution
Have multiple delay queues depending on routing key.
OR
Do not associate the delay queue with a routing key and use stamps to handle the routing key (not sure if this is possible)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions