8000 [Messenger] Infinite retries depending on exceptions · Issue #36182 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Messenger] Infinite retries depending on exceptions #36182

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

Closed
Braxilior opened this issue Mar 23, 2020 · 1 comment · Fixed by #36185
Closed

[Messenger] Infinite retries depending on exceptions #36182

Braxilior opened this issue Mar 23, 2020 · 1 comment · Fixed by #36185

Comments

@Braxilior
Copy link

Description
In some cases you know that it is useless to retry again and you can use the UnrecoverableMessageHandlingException.
However, you have no way to do the opposite: retry indefinitely until your message is successfully handled.

For example
My handlers can fail due to various exceptions but for a specific one (let's call it RetryLaterException) I want to retry until the message is successfully handled.
I can try to implement a RetryStrategy which looks like this

  • the message needs to be "re-delivered" due to a RetryLaterException: always retry with a constant delay
  • else: use the MultiplierRetryStrategy
    but this is not possible because you don't have access to the exceptions inside the RetryStrategyInterface.

Some ideas

  • add an event listener to handle this case before the SendFailedMessageForRetryListener. This requires the WorkerMessageFailedEvent to support the stopPropagation method.
  • add a stamp that you can look for in your custom RetryStrategy. Currently, there is now way to add a stamp when an exception is thrown. When an exception is thrown in the HandleMessageMiddleware, it is directly caught by the Worker.
  • send the message to a different transport with a different RetryStrategy for some specific exceptions
@Tobion
Copy link
Contributor
Tobion commented Mar 23, 2020

I already proposed somwhere that RetryStrategyInterface should get the exception as argument (optional for BC). Can you work on a PR? You have my approval for this.

@fabpot fabpot closed this as completed Apr 4, 2020
fabpot added a commit that referenced this issue Apr 4, 2020
…Interface methods (Benjamin Dos Santos)

This PR was squashed before being merged into the 5.1-dev branch.

Discussion
----------

[Messenger] Add a \Throwable argument in RetryStrategyInterface methods

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no
| Tickets       | Fix #36182
| License       | MIT

This allows to define new retry strategies based on the exceptions thrown during the last handling.

Commits
-------

5fa9d68 [Messenger] Add a \Throwable argument in RetryStrategyInterface methods
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants
0