-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Messenger] Why are you forced to specify a "default bus"? #32030
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Can you try using named autowiring aliases? |
Yeah, that will work. But if I name a variable |
Oh, I agree! I even thought it was the case when I first contributed around this :) |
The default bus requirement is currently enforced mainly because of
Not sure what the best solution for 1. would be. Require people to specify the bus in this method? |
Ref. #31662 |
The downside to making So, if we make it optional, I think that should be considered. |
I was thinking about how to fix this and also the third point in #32049: |
Hmm, this very well may make sense. If you have one bus only, you would not need this config. If you had multiple buses, then each transport would need a bus to be defined. And there would be no validation - I.e. you could in theory dispatch to bus B and transportFoo, then configure transportFoo to dispatch back to busA, correct? I think that makes enough sense. But, strictly speaking for this issue, wasn’t the “default” bus (#31288) added just as a nice “fallback” if the stamp were missing? We could just remove that (or deprecate it). We need an argument behind just this issue to change the bus name stamp logic I think. I think your motivation is about making custom, non-messenger-originates messages easier to work with? We could do that by adding your option to each transport as an “override”. I mean, if that option is set, use that bus. Else, use the BusNameStamp. Else, an exception (remove the default bus from routable). I’m debating between this option + the stamp (“easier” as normal users never new to think about this option) vs only the option and remove the stamp (a bit more work for users with multiple buses, but more explicit). Cheers! |
I thoroughly agree with this. I'm erring towards not using the framework configuration and just defining the messengers manually through |
I think the BusNameStamp is bad because it does not respect that message handling is async. If you dispatch a message with bus A and delay (or it goes into retry), then rename the bus and redeploy, the message cannot be consumed suddenly because bus A does not exist anymore. This is why explicitly setting the bus on the transport seems like the best solution. |
Thank you for this issue. |
Yes, I think it has been. I suggest no changes. |
Description
When configure your busses it could look like this:
Since we are using multiple busses we are forced to define
default_bus
. Why?I understand it is for autowire but what if I dont want it to autowire?
The issue is the following:
I define my services like
So if I create two PHP classes like this:
Foo
will get an instance of mymessenger.bus.event
andBar
will get an instance ofmessenger.bus.command
. You would expectBar
to getmessenger.bus.query
, but I've forgotten to add that underservices._default.bind
and autowire "helps" me to get the configureddefault_bus
.I would much rather not define a
default_bus
and then get an exception since it cannot autowireMessageBusInterface $queryBus
.Im sure there is a reason why we need a
default_bus
but I cannot see it.The text was updated successfully, but these errors were encountered: