Description
Symfony version(s) affected: 4.1+
Description
The messenger:consume
command "receives" messages from a transport and then sends them back into the bus. But if you have multiple busses, the command requires you to choose which bus you want. This is incorrect: the message should automatically be sent back through the correct bus.
For example:
MessageA
goes throughBusA
and is sent toTransportFoo
MessageB
goes throughBusB
and is also sent toTransportFoo
Now, if I run messenger:consume
and choose BusA
, I will receive & send both MessageA
AND MessageB
through BusA
. This means that MessageB
will incorrectly go through BusA.
But what about messages that are sent to the queue from an external app and only consumed by Messenger? In that case, I think we need to send to the default bus and/or allow the bus to be configured on a transport-by-transport basis.
Possible Solution
The bus name should be attached via a stamp and read by the Worker
to determine which bus to send to. I think the only way to do that is to pass a new BusNameMiddleware automatically into each MessageBus as the first middleware that knows the name and can add a stamp. That’s only a little weird because component users would need to know that this middleware needs to be added when creating the MessageBus. Or am I missing another way?
For messages received from an external system (no SentStamp
), there would need to be sent to the "default" bus, or allow the bus to be configured for that transport.