-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Messenger] fromTransport in attribute not working #48529
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
Can you create a small example application that allows to reproduce your issue? |
I am going to close here for now due to the lack of feedback. Please let us know when you have more information and we can consider to reopen. |
I think this is still an issue on 6.3 – |
…ports` (valtzu) This PR was merged into the 6.3 branch. Discussion ---------- [Messenger] Fix message handlers with multiple `from_transports` | Q | A | ------------- | --- | Branch? | 6.3 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | Fix #48529 | License | MIT When you define multiple `AsMessageHandler` attributes or `messenger.message_handler` tags with otherwise same definitions but with different transports, the last definition overwrites all previous ones, despite `debug:messenger` showing it correctly: ``` The following messages can be dispatched: -------------------------------------------------------------------------------------------------------------------- App\Message\TriggeringMessage handled by App\MessageHandler\TriggeringMessageHandler (when from_transport=a) handled by App\MessageHandler\TriggeringMessageHandler (when from_transport=b) handled by App\MessageHandler\TriggeringMessageHandler (when method=handleTriggeringMessage, from_transport=a) handled by App\MessageHandler\TriggeringMessageHandler (when method=handleTriggeringMessage, from_transport=b) ``` Example code: ```php #[AsMessageHandler(fromTransport: 'a', handles: TriggeringMessage::class)] #[AsMessageHandler(fromTransport: 'b', handles: TriggeringMessage::class)] class TriggeringMessageHandler { public function __invoke(): void { echo __FUNCTION__."\n"; } #[AsMessageHandler(fromTransport: 'a', handles: TriggeringMessage::class)] #[AsMessageHandler(fromTransport: 'b', handles: TriggeringMessage::class)] public function handleTriggeringMessage(): void { echo __FUNCTION__."\n"; } } ``` When sending a `TriggeringMessage` to both `a` & `b` transports, I get following `bin/console messenger:consume a b` output on **6.3**: ``` [critical] Error thrown while handling message App\Message\TriggeringMessage. Removing from transport after 0 retries. Error: "No handler for message "App\Message\TriggeringMessage"." __invoke handleTriggeringMessage ``` And with this fix: ``` __invoke handleTriggeringMessage __invoke handleTriggeringMessage ``` Commits ------- bff3cc1 Fix message handlers with multiple from_transports
Symfony version(s) affected
5.4
Description
Handler attribute with fromTransport option not working
and every handler is executed.
After adding the method with configuration, it works as intended:
How to reproduce
Handlers:
Possible Solution
No response
Additional Context
No response
The text was updated successfully, but these errors were encountered: