-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Messenger] DispatchAfterCurrentBusMiddleware does not cancel messages from delayed handlers #32370
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
Ping @Nyholm - need your expert eyes on this - it's a tricky feature :) |
Thank you for the ping. This is an excellent issue description. And yes, it is a tricky bug. Hm. You are correct. You can do an infinite chain of “dispatch message after current buss”. Bastien: do you want to give a try to implement a solution? |
I added some tests bug (I think). See Nyholm@35c76a3 |
…cel messages from delayed handlers (Nyholm, BastienClement) This PR was merged into the 4.3 branch. Discussion ---------- [Messenger] DispatchAfterCurrentBusMiddleware does not cancel messages from delayed handlers | Q | A | ------------- | --- | Branch? | 4.3 for bug fixes | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? |no | Tests pass? | yes (thanks @Nyholm) | Fixed tickets | #32370 | License | MIT | Doc PR | - This is a fix for #32370. There is no need for anything sophisticated. There is no recursion or fancy stuff going on, just a queue of message handled sequentially. A simple variable is enough to keep track of the queue state. Thanks @Nyholm for the test, it would clearly have been the hardest part of the job. Commits ------- 1f5c8a6 Cancel delayed message if handler fails 35c76a3 Added tests for #32370
* 4.3: [Routing] Add a param annotation for $annot. [DI] fix docblock [Console] fix docblock Add missing translations for Armenian locale [Process] Added missing return type. [Process] Doc block backport. Added doc block for Registry::supports(). [Cache] Fix predis test Don't duplicate addresses in Sendgrid Transport Remove unnecessary statement Fix some docblocks. [Messenger] make delay exchange and queues durable like the normal ones by default Cancel delayed message if handler fails Added tests for #32370
* 4.4: [Routing] Add a param annotation for $annot. [DI] fix docblock [Console] fix docblock Add missing translations for Armenian locale [Process] Added missing return type. [Process] Doc block backport. Added doc block for Registry::supports(). [Cache] Fix predis test Don't duplicate addresses in Sendgrid Transport Remove unnecessary statement Fix some docblocks. [Messenger] make delay exchange and queues durable like the normal ones by default Cancel delayed message if handler fails Added tests for #32370
Uh oh!
There was an error while loading. Please reload this page.
Symfony version(s) affected: 4.3.1
Description
When an exception is thrown during the handling of the first message, the queue is flushed and delayed messages which might already have been dispatched are "canceled".
On the other hand, if a delayed message handler throws an exception, it is simply collected without any queue cleanup being done.
Therefore, the
DispatchAfterCurrentBusStamp
semantic is not the same whether we are in the first message handler or a delayed one. In the first case an exception "cancels" previously sent messages, in the second case it does not. I believe this is not intended since the messenger documentation clearly states (as an unintended consequences):How to reproduce
Message A
dispatches (after current bus)Message B
and returns,Message B
dispatches (after current bus)Message C
but then throws an exception,Message C
is handled despite its dispatcher having thrown an exceptionPossible Solution
Either:
Additional context
n/a
The text was updated successfully, but these errors were encountered: