-
-
Notifications
You must be signed in to change notification settings - Fork 9.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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
weaverryan
reviewed
May 3, 2020
@@ -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 the HandlerFailedException
case where you need to check for the nested exceptions?
Also, a new test case for the listener would be ideal :)
weaverryan
approved these changes
May 4, 2020
(small rebase needed) |
nicolas-grekas
approved these changes
May 4, 2020
cc6a739
to
1d385aa
Compare
rebased |
fabpot
approved these changes
May 4, 2020
1d385aa
to
e7c3167
Compare
Thank you @jderusse. |
Merged
fabpot
added a commit
that referenced
this pull request
May 12, 2023
…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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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: