Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.6k
[Messenger] Add support for RecoverableException#36557
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
@@ -87,6 +88,10 @@ public static function getSubscribedEvents() | |||
private function shouldRetry(\Throwable $e, Envelope $envelope, RetryStrategyInterface $retryStrategy): bool | |||
{ | |||
if ($e instanceof RecoverableExceptionInterface) { | |||
return true; | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
What about theHandlerFailedException
case where you need to check for the nested exceptions?
Also, a new test case for the listener would be ideal :)
(small rebase needed) |
rebased |
Thank you@jderusse. |
…rategy for re-delivery (FlyingDR)This PR was merged into the 5.4 branch.Discussion----------[Messenger] Respect `isRetryable` decision of the retry strategy for re-delivery| Q | A| ------------- | ---| Branch? | 5.4| Bug fix? | yes| New feature? | no| Deprecations? | no| Tickets || License | MIT| Doc PR |[Documentation](https://symfony.com/doc/5.4/messenger.html#retries-failures) for retry strategy for the Messenger component declares that message will not be retried to be re-delivered more than the value of `max_retries` configuration for the retry strategy.However, after merging#36557 [actual implementation](https://github.com/symfony/symfony/blob/39cd93a9f7ea072b26853e87ceb1142d6dd019b0/src/Symfony/Component/Messenger/EventListener/SendFailedMessageForRetryListener.php#L126-L128) gives priority to the existence of the `RecoverableExceptionInterface`, effectively opening a way for a message to be re-delivered indefinitely.Additionally, in the case of using `multiplier` with a value of more than 1 this unlimited re-delivery causes unlimited growth of the `delay` value for the `DelayStamp`. Its type is defined as `int`, so on 32-bit platforms after some time `delay` value may exceed `PHP_INT_MAX` which will lead to the `TypeError`.The proposed change enforces respect for the `max_retries` setting value for the decision of re-delivery.Commits-------8fc3dcc [Messenger] Respect `isRetryable` decision of the retry strategy when deciding if failed message should be re-delivered
The messenger supports the
UnrecoverableException
preventing the messenger retry mechanismwhen the Handler will never be able to process the Message.
This PR adds the opposite behavior to always retry the message.
UseCase: