Skip to content

[Messenger] Infinite retries depending on exceptions #36182

@Braxilior

Description

@Braxilior

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

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