Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
fabpot merged 1 commit intosymfony:masterfromweaverryan:middleware-events
Mar 23, 2019

Conversation

@weaverryan
Copy link
Member

@weaverryanweaverryan commentedMar 22, 2019
edited
Loading

QA
Branch?master
Bug fix?no
New feature?yes
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed ticketsnone
LicenseMIT
Doc PRTODO

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 addexhaustive 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:

class MailerMessageSendToTransportEventSubscriberimplements EventSubscriberInterface{publicfunctiononSendMessage(SendMessageToTransportsEvent$event)    {$envelope =$event->getEnvelope();if (!$envelope->getMessage()instanceof SomeMailerMessage) {return;        }$event->setEnvelope($envelope->with(newAmpqRoutingKeyStamp('mailer-route')));    }publicstaticfunctiongetSubscribedEvents()    {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

@weaverryan
Copy link
MemberAuthor

This should be ready to go

@fabpot
Copy link
Member

Thank you@weaverryan.

@fabpotfabpot merged commita7ad1b4 intosymfony:masterMar 23, 2019
fabpot added a commit that referenced this pull requestMar 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        | TODOAlternative 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:```phpclass 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 itCommits-------a7ad1b4 Dispatching two events when a message is sent & handled
@fabpotfabpot mentioned this pull requestMay 9, 2019
@HypeMCHypeMC mentioned this pull requestOct 19, 2025
nicolas-grekas added a commit that referenced this pull requestOct 20, 2025
This PR was merged into the 7.4 branch.Discussion----------[Messenger] Simplify code| Q             | A| ------------- | ---| Branch?       | 7.4| Bug fix?      | no| New feature?  | no| Deprecations? | no| Issues        | -| License       | MITNoticed while working on#61843.There's no reason for the event to be dispatched inside the loop anymore:1. The event was [originally dispatched outside the loop](#30650).2. It was later [moved inside the loop](#30676) because of the retry mechanism.3. [The retry mechanism was later extracted](#34185), so there's no longer a need for the event to be dispatched inside the loop.Commits-------beeb4b9 [Messenger] Simplify code
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@fabpotfabpotfabpot approved these changes

+1 more reviewer

@srozesrozesroze approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@weaverryan@fabpot@sroze@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp