[Messenger] allow to change the message name#29045
[Messenger] allow to change the message name#29045Tobion wants to merge 1 commit intosymfony:masterfrom
Conversation
|
The serializing part loses the name - that's why I added it as a stamp in a previous PR. |
|
Let's say there is a message with arbitrary data and you want to route to handlers based on the data of the message. |
|
8000
+1 to changing the interface back so it accepts an As for responsibilities, this is how I see things:
|
…es (nicolas-grekas) This PR was merged into the 4.2-dev branch. Discussion ---------- [Messenger] make senders/handlers locator accept envelopes | Q | A | ------------- | --- | Branch? | 4.2 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - As suggested by @Tobion in symfony/symfony#29045 (comment) - works for me also. Commits ------- 9cd88b0dc5 [Messenger] make senders/handlers locator accept envelopes
…es (nicolas-grekas) This PR was merged into the 4.2-dev branch. Discussion ---------- [Messenger] make senders/handlers locator accept envelopes | Q | A | ------------- | --- | Branch? | 4.2 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - As suggested by @Tobion in #29045 (comment) - works for me also. Commits ------- 9cd88b0 [Messenger] make senders/handlers locator accept envelopes
|
Replaced by #29052. The rest can be implemented manually or in future symfony versions. |
…es (nicolas-grekas) This PR was merged into the 4.2-dev branch. Discussion ---------- [Messenger] make senders/handlers locator accept envelopes | Q | A | ------------- | --- | Branch? | 4.2 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - As suggested by @Tobion in symfony/symfony#29045 (comment) - works for me also. Commits ------- 9cd88b0dc5 [Messenger] make senders/handlers locator accept envelopes
Having the class name as default for the message name is the best practice and usually does not need to be changed. But I think we need to provide a way to do so for just for flexibility. This allows people to opt-out of interface/parent class based routing (#28993) by manually calling
$bus->dispatch(Envelope::createNamed($message, 'foo')). IMO we don't need to add an optional name parameter to thedispatchmethod like originally proposed in #28944 since it's an edge case that does not need to be exposed at the primary entry point.