Skip to content

[messenger] \Symfony\Component\Messenger\Middleware\RejectRedeliveredMessageMiddleware do not run retry logic as intended #52903

@itcodeOstrowski

Description

@itcodeOstrowski

Symfony version(s) affected

6.4

Description

Hello,

If messages retrieved from the queue with $amqpReceivedStamp->getAmqpEnvelope()->isRedelivery() are true, the RejectRedeliveredMessageException will be thrown in RejectRedeliveredMessageMiddleware. This should cause the default retry logic to run, but because RejectRedeliveredMessageException implements UnrecoverableExceptionInterface, and because in the SendFailedMessageForRetryListener::shouldRetry() logic we check for UnrecoverableExceptionInterface, the retry logic is not triggered.

How to reproduce

  1. Consume message that has Redelivered stamp.
  2. Message should be queued again with default retry logic, but instead it is gone.

Possible Solution

Just revert that commit: symfony/messenger@2479dc6 (i don't understand intention of this commit, maybe just use \Symfony\Component\Messenger\Exception\RecoverableExceptionInterface instead) or change description of \Symfony\Component\Messenger\Middleware\RejectRedeliveredMessageMiddleware because it is misleading otherwise.

Additional Context

interesting classes:
\Symfony\Component\Messenger\Middleware\RejectRedeliveredMessageMiddleware
\Symfony\Component\Messenger\Exception\RejectRedeliveredMessageException
\Symfony\Component\Messenger\EventListener\SendFailedMessageForRetryListener::shouldRetry

This bug makes usage of rabbitMQ much more difficult because now it is not possible to check messages in web interface, if the check is done, it would be not possible to use that message.

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