Is it possible to define binding between exchanges in Symfony messenger component? (4.4 version here).
I know that it's possible binding exchange to the queue like here:
transports:
incoming:
dsn: "%env(RABBITMQ_SHARED_URL)%"
options:
queues:
app.pl_incoming_events:
binding_keys:
- pl.app.#
exchange:
name: my_app.incoming
type: topic
And then app setups exchange, queue and binding between them. I'd expect the same effect to bind exchange to another exchange basing on the routing key.
I know that I can use rabbitmq-bundle but IMO is redundant - I'd like to stay with one component for managing rabbitMQ.
For instance I'd like to bind other_app
exchange to my_app.incoming
exchange basing on some route key.
Messenger is not a RabbitMQ manager, you cannot even declare multiple exchanges in the same transport out of the box. But since it has all the required components and in this case symfony is a bit permissive with the config, you can abuse the system and build it yourself.
Since I don't know your requirements I'll keep it basic, hopefully it'll get you started.
Start by creating
AmqpTransportFactory
:Register the service:
Add the new configuration to the exchange:
And it will result on the following bindings: