Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.6k
[Messenger] IntroduceDeduplicateMiddleware
#54141
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
306a8e7
to0b67664
CompareThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I like the idea, and using the lock component provides a simple solution.
I wonder if this should be namedLockMiddleware
orDedupplicationMiddleware
. At first I though this PR was about avoid processing similar messages in parallel.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
e04298b
to05dcb17
CompareUh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
495364f
toe8b1f4f
CompareUh oh!
There was an error while loading.Please reload this page.
$envelope = $stack->next()->handle($envelope, $stack); | ||
} finally { | ||
// If we've received a lockable message, we're releasing it. | ||
if (null !== $envelope->last(ReceivedStamp::class)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I think this is not necessary, the check is performed in the releaseLock method.
Also, it's not consistent with the call$this->releaseLock($envelope, true);
at line 64
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
For$this->releaseLock($envelope, true);
the check on theReceivedStamp
is done because I do:
if (null === $envelope->last(ReceivedStamp::class)) { // foo} else { $this->releaseLock($envelope, true);}
AndreleaseLock
is not doing the any check onReceivedStamp
, but onLockStamp
.
If I don't do theReceivedStamp
check, I will release the lock right after adding the lock (during the first dispatch) instead of when I receive the message.
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
5cf5b1d
tod1ae96c
CompareUh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTestCase.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Oh, and a line is missing in the changelog |
b48b5bb
to41c0b2f
Comparepounard commentedOct 25, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@VincentLanglet I want to apologize for having misunderstood the original issue. Please ignore all my comments. May I suggest renaming the whole to something much more specific and explicit about what it does and why, such as@jderusse suggested in one the first comments? Some suggestions about how I would name those classes:
Because the "Lock" term may mislead to "contention" or "conflict" problem resolution, such as deadlocks or transaction failures in database for example, but in my opinion doesn't ring any bell about deduplication. Once the deduplication thing rang a bell in my mind, it completely wiped out the idea of using it for delaying messages or avoiding parallel processing: it is indeed a very different use case, but one that would also be resolved using a lock/mutex. Hence the wrong naming that could mean very different things. Any opinion about this@nicolas-grekas? |
LockMiddleware
DeduplicateMiddleware
2b1da0d
tob125c9d
CompareUh oh!
There was an error while loading.Please reload this page.
Hi@nicolas-grekas@jderusse@welcoMattic@xabbuh It's unclear to me how to move this forward. |
welcoMattic left a comment• edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
It look good to me. If possible to rebase the branch and squash commits@VincentLanglet, it will make the merge easier. Thanks for your contribution!
b125c9d
to3f68223
Compare3f68223
toaa7000a
Compare
Rebased and squashed |
Thank you@VincentLanglet. |
0b9c488
intosymfony:7.3Uh oh!
There was an error while loading.Please reload this page.
if (class_exists(DeduplicateMiddleware::class)) { | ||
$this->assertEquals([ | ||
['id' => 'add_bus_name_stamp_middleware', 'arguments' => ['messenger.bus.commands']], | ||
['id' => 'reject_redelivered_message_middleware'], | ||
['id' => 'dispatch_after_current_bus'], | ||
['id' => 'failed_message_processing_middleware'], | ||
['id' => 'deduplicate_middleware'], | ||
['id' => 'send_message', 'arguments' => [true]], | ||
['id' => 'handle_message', 'arguments' => [false]], | ||
], $container->getParameter('messenger.bus.commands.middleware')); | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
update the test deps next time to avoid these exra conditions :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
it's all maintenance
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
cc@fabpot
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
There’s not really a need to forbid using FrameworkBundle with Messenger < 7.3. But that would be the consequence if we cannot test it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
i dont like the if/else condition based on class presence generally
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
7.2 is tested without class X
7.3 is tested with class X
it's that simple to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
That would complicate things. Either we would require people to update FrameworkBundle and components at the same time which would make updating harder. Or we would not be able to test the bundle with the lowest deps which would not allow us to detect compatibility issues.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
we would require people to update FrameworkBundle and components at the same time which would make updating harder
generally yes, it that prevents if/else flows in your codebase. We should prefer branches then.
updating many sf packages from 7.2 to 7.x is not an issue.
Uh oh!
There was an error while loading.Please reload this page.