-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Messenger] Introduce #[AsMessage]
attribute for message routing
#57507
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
[Messenger] Introduce #[AsMessage]
attribute for message routing
#57507
Conversation
All tests failures seems unrelated, and seem happen in conjunction with some Doctrine ORM versions. |
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.
Works for me, here are some minor comments.
src/Symfony/Component/Messenger/Transport/Sender/SendersLocator.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Messenger/Transport/Sender/SendersLocator.php
Outdated
Show resolved
Hide resolved
a024c4c
to
0e42fda
Compare
@nicolas-grekas @yceruto all done, thanks for the review. |
Same unrelated failures again in |
#[AsMessage]
attribute for message routing
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.
small rebase needed
…essage routing
3ad89ad
to
d652842
Compare
Did it, CI failures are still related to doctrine. |
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.
Thanks for your answers. Works for me.
I'd like to thank you for your time, I appreciate it very much. |
@nicolas-grekas Will this be merged? I need to know in order to continue experimenting/proposing new features for the messenger. |
I'd like to wait a bit in case anyone else would like to review, but eventually I think it should be merged yes. |
@nicolas-grekas in the meantime, I'd like to have your global impressions about #57536 if you can find a few minutes for 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 like it!
The attributes are retrieved at runtime. As questioned in #41179 (comment), is this a problem?
I don't think so, reflection is fast and it probably will be insignificant compared to the command execution itself. EDIT: here we are at dispatch, so it actually will not be executed, yet it is still way faster than the database insert that will be issued if the transport is doctrine-based, or anyother tcp round-trip if it is another type of broker. |
I think this also but wanted to confirm. |
Thank you @pounard. |
Thanks! |
This PR was merged into the 7.2 branch. Discussion ---------- [Messenger] Document `#[AsMessage]` attribute Fixes #20002 Document the newly merged `#[AsMessage]` attribute symfony/symfony#57507 Commits ------- a381536 [Messenger] document the #[AsMessage] attribute
Basic implementation of #57506.
Symfony\Component\Messenger\Attribute\AsMessage
attribute, with the$transport
parameter which can bestring
orarray
.Symfony\Component\Messenger\Transport\Sender\SendersLocator
.Rationale:
Symfony\Component\Messenger\Stamp\TransportNamesStamp
will always override the attribute values, allowing users to change hardcoded routing on a per-environment basis.Links and references:
AsRoutedMessage
attribute #49143 closed PR that was doing the same, but at compile time, rejected because the actual doctrine is that messages should never be services.