Skip to content

[Messenger] Ability to route a subclass to a different transport without duplicating the message #36349

@Seldaek

Description

@Seldaek

Description
This might be considered a bug, or maybe it's just a feature which can not be changed, but anyway..

While trying to implement email routing to different messenger transport (which lead to #36348), at first I had simply defined one additional SendUrgentEmailMessage class which extended the Mailer component's SendEmailMessage, and then I tried defining routing as such:

        routing:
            'App\SendUrgentEmailMessage': async_urgent
            'Symfony\Component\Mailer\Messenger\SendEmailMessage': async

The problem is when sending a SendUrgentEmailMessage message through the messenger component, it appears to get sent and handled, but then gets sent again somehow and fails to find a handler as the message has a handled stamp already so it ignores the MessageHandler.

It appears that what causes it is that App\SendUrgentEmailMessage extends the other, so when looking for where to route the message, it is routed to both async_urgent and async.

So the question here is.. is this expected, is this desired, etc?

I worked around it by extending a second time into App\SendEmailMessage so that I have now two specific classes to route independently, but I feel like it shouldn't be needed somehow.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions