-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[RFC][Messenger] General message retry mechanism #27215
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
Comments
I have created a POC retry system with just a few extension points added to the framework. I understand that how retries work can be very opinionated. My sample flex app is here with the specific changes from an out of the box flex website-skeleton here. Some notes on how the app's bus works:
In order to make this work, I had to make 3 changes to Symfony:
Anyway, this scope of this issue has grown pretty large but I just wanted to share a possible use-case I see for the component and where the the blockers are in Symfony. |
Ideally, I'd like to see Of course, for synchronous message buses you would want the actual exception thrown - this could be done with a default middleware that unwraps the |
This is still a thing as it is currently not possible to built a retry mechanism that takes into account that just one of many handlers had failed and on redelivery just the failed handlers should be called again.
Combined this would lead to the possibility of just redelivering the message by dispatching the modified envelope, what can be easily achieved with a custom middleware. IMHO this redelivering mechanism is not necessarily part of the Framework, because it will depend on custom circumstances, like if the used transport already brings an redelivering mechanism, or if the redelivering should be delayed, etc. But in general it should be possible to build a solid retry mechanism. Let me know what you think, i'll happilly prepare a PR for this one. |
… (weaverryan) This PR was merged into the 4.3-dev branch. Discussion ---------- [Messenger] Worker events + global retry functionality | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | yes, on Messenger only | Deprecations? | no | Tests pass? | NEEDED | Fixed tickets | #29132, #27008, #27215 and part of #30540 | License | MIT | Doc PR | TODO This is an alternative to #29132 and #27008. There are several big things: 1) The `messenger:consume` does not die if a handler has an error 2) Events are dispatched before, after and on error a message being handled 3) Logic is moved out of Amqp and into the Worker so that we can have some consistent features, like error handling. 4) A generic retry system was added, which works with Amqp and future transports should support. It will work out of the box for users. Retrying works by putting the received `Envelope` back into the bus, but with the `ReceivedStamp` removed. The retry functionality has an integration test for AMQP. 5) Added a new `MessageDecodingFailedException` that transport Serializers should throw if `decode()` fails. It allows us to reject a message in this situation, as allowing it to fail but remain on the queue causes it to be retried forever. 6) A new `DelayStamp` was added, which is the first of (later) more stamps for configuring the transport layer (see #30558). BC breaks are documented in the CHANGELOG. Thanks! Commits ------- a989384 Adding global retry support, events & more to messenger transport
…ndler (keulinho, sroze) This PR was merged into the 4.3-dev branch. Discussion ---------- [Messenger] Ensure message is handled only once per handler Add check to ensure that a message is only handled once per handler Add try...catch to run all handlers before throwing exception | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? |no | Tests pass? | yes | Fixed tickets | #27215 | License | MIT | Doc PR | Todo This would make error handling and retrying of messages much more easier. As statet here #27008 (comment) there is currently no way to retry a for all failed handlers if there are mutliple handlers and just some throw an exception. Also if an Exception in an handler occurs the execution chain is disrupted and the other handlers are never invoked. With this change it is easily possible to create an userland middleware that catches the `ChainedHandlerFailedException` and does some custom retry logic. If you ensure that the `HandledStamps` on the `Envelope` are preserved the message will be handled just by the failed handlers Commits ------- 2e5e910 Rename exception, add change log and a few other things e6e4cde Ensure message is handled only once per handler
This was initially discussed in #27008 (comment) and #27008 (comment). That PR is for an AMQP-specific retry mechanism but it got me thinking of a more general retry system.
I am opening this issue to discuss further.
Here are some thoughts I have on this:
$maxRetry
(and probably a$delay
). Maybe at the handler level, maybe not...The text was updated successfully, but these errors were encountered: