-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Dispatching two events when a message is sent & handled #30650
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8083077
to
49d3c46
Compare
36 tasks
sroze
suggested changes
Mar 23, 2019
src/Symfony/Component/Messenger/Middleware/SendMessageMiddleware.php
Outdated
Show resolved
Hide resolved
49d3c46
to
04fcf90
Compare
04fcf90
to
a7ad1b4
Compare
This should be ready to go |
sroze
approved these changes
Mar 23, 2019
fabpot
approved these changes
Mar 23, 2019
Thank you @weaverryan. |
fabpot
added a commit
that referenced
this pull request
Mar 23, 2019
…d (weaverryan) This PR was merged into the 4.3-dev branch. Discussion ---------- Dispatching two events when a message is sent & handled | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | none | License | MIT | Doc PR | TODO Alternative to #30646. This uses a more generic system, so you could do anything when a message is sent. The main use-case is when a message is dispatched by a 3rd party. I didn't try to add *exhaustive* events everywhere: I added an event for a very specific use-case: When a message is dispatched by a 3rd party, being able to add stamps (e.g. `DelayStamp` or a future `AmqpRoutingKeyStamp` before the message is sent. Example: ```php class MailerMessageSendToTransportEventSubscriber implements EventSubscriberInterface { public function onSendMessage(SendMessageToTransportsEvent $event) { $envelope = $event->getEnvelope(); if (!$envelope->getMessage() instanceof SomeMailerMessage) { return; } $event->setEnvelope($envelope->with(new AmpqRoutingKeyStamp('mailer-route'))); } public static function getSubscribedEvents() { return [SendMessageToTransportsEvent::class => 'onSendMessage']; } } ``` Along with #30557, we will now have the following events, regarding async messages: * Event when a message is sent to transports (this PR) * Event when a message is received from transport, but before handling it * Event when a message is received from transport and after handling it Commits ------- a7ad1b4 Dispatching two events when a message is sent & handled
25 tasks
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Alternative to #30646. This uses a more generic system, so you could do anything when a message is sent. The main use-case is when a message is dispatched by a 3rd party.
I didn't try to add exhaustive events everywhere: I added an event for a very specific use-case:
When a message is dispatched by a 3rd party, being able to add stamps (e.g.
DelayStamp
or a futureAmqpRoutingKeyStamp
before the message is sent. Example:Along with #30557, we will now have the following events, regarding async messages: