Skip to content

[Messenger] Support transport attribute on messenger.message_handler tag #33306

Closed
@ruudk

Description

@ruudk

I know it's possible to bind certain handlers to a specific transport but that only works when the handler implements MessageSubscriberInterface.

In my case, I use autowire to automatically tag my handlers. I split my handlers in 2 directories like this:

src/Handler/Asynchronous
src/Handler/Synchronous

And then register them using:

    App\Handler\Asynchronous\:
        resource: 'src/Domain/Handler/Asynchronous'
        tags: [{ name: 'messenger.message_handler', bus: 'command.bus'  }]
    App\Handler\Synchronous\:
        resource: 'src/Domain/Handler/Synchronous'
        tags: [{ name: 'messenger.message_handler', bus: 'command.bus'  }]

It would be great if I could add transport: async and transport: sync to automatically select the transport for the given handlers:

    App\Handler\Asynchronous\:
        resource: 'src/Domain/Handler/Asynchronous'
        tags: [{ name: 'messenger.message_handler', bus: 'command.bus', transport: 'async'  }]
    App\Handler\Synchronous\:
        resource: 'src/Domain/Handler/Synchronous'
        tags: [{ name: 'messenger.message_handler', bus: 'command.bus', transport: 'sync'  }]

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