Skip to content
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] Message attributes #41106

Closed
ro0NL opened this issue May 4, 2021 · 4 comments · Fixed by #43588 · May be fixed by #41179
Closed

[Messenger] Message attributes #41106

ro0NL opened this issue May 4, 2021 · 4 comments · Fixed by #43588 · May be fixed by #41179

Comments

@ro0NL
Copy link
Contributor

ro0NL commented May 4, 2021

Eg.

#[Handler(Some::class)]
#[Handler(Other::class)]
#[Route('sync')]

As replacements/alternatives for

        'routing' => [
            'App\Message\SmsNotification' => 'sync',
        ],

and MessageHandlerInterface 🤪

Perhaps it's considerable to expose some tools in a contract package, for other bus implementors to leverage. But Messenger component will do i guess. We could even think of a interop messge bus contract.

@maxim-dovydenok
Copy link
Contributor

I like the idea to configure transport using attributes. I will create a PR with the "Senders" attribute. I called it Senders instead of Route, because as I understand "routing" concept is part of the Framework bundle, and in the Messenger, there're only senders. If it's not right, then I'll change it in the pull request.

As for Handlers, I'm not sure that it's the right solution. From my point of view, Messages should not know about the Handlers, and I prefer how it's done now in the Framework bundle. I would like to hear someone's feedback, but I can work on this attribute as well.

@ro0NL
Copy link
Contributor Author

ro0NL commented May 12, 2021

You are right. Im not sure what #[Handler] would actually be conveying from the message POV 😓 probably only creating some bidirectional relation.

What if an attribute could replace MessageHandlerInterface on the handler side, eg. to classify any handler callable. Perhaps it enables more interop value ...

@maxim-dovydenok
Copy link
Contributor

What if an attribute could replace MessageHandlerInterface on the handler side, eg. to classify any handler callable. Perhaps it enables more interop value ...

We can add AsMessageHandler attribute as a replacement for a marker interface MessageHandlerInterface. There're AsCommand, AsEventListener, AsController attributes already.

@ro0NL
Copy link
Contributor Author

ro0NL commented Aug 20, 2021

see #41202

@ro0NL ro0NL closed this as completed Aug 20, 2021
Tobion added a commit that referenced this issue Oct 25, 2021
…assi)

This PR was squashed before being merged into the 5.4 branch.

Discussion
----------

[Messenger] Autoconfigurable attributes

| Q             | A
| ------------- | ---
| Branch?       | 5.4
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no
| Tickets       | Fix #41106
| License       | MIT
| Doc PR        | symfony/symfony-docs#15990

Commits
-------

f27e594 [Messenger] Autoconfigurable attributes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment