You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
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.
…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
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 thisRetryLaterException
: always retry with a constant delayMultiplierRetryStrategy
but this is not possible because you don't have access to the exceptions inside the
RetryStrategyInterface
.Some ideas
SendFailedMessageForRetryListener
. This requires theWorkerMessageFailedEvent
to support thestopPropagation
method.RetryStrategy
. Currently, there is now way to add a stamp when an exception is thrown. When an exception is thrown in theHandleMessageMiddleware
, it is directly caught by theWorker
.RetryStrategy
for some specific exceptionsThe text was updated successfully, but these errors were encountered: