As explained in the documentation of the Symfony messenger component, by default message handlers handle messages from all message buses. However, one can restrict a message handler to a specific bus like this:
# config/services.yaml
services:
App\MessageHandler\SomeCommandHandler:
tags: [{ name: messenger.message_handler, bus: command.bus }]
# prevent handlers from being registered twice (or you can remove
# the MessageHandlerInterface that autoconfigure uses to find handlers)
autoconfigure: false
Now for a project I am working on, I have three buses, and I would like a handler to only handle messages on two of those buses.
Is anybody aware of a way to achieve this?