[FrameworkBundle][Messenger] Add support for namespace wildcard in Messenger routing #48531
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a new feature for the Messenger component which is why there is no issue ticket attached.
Currently, HandlersLocator extracts message class along with all parent classes and all interfaces + a
'*'
wildcard to match any transport.This is not fully efficient resulting in many routes for messages that share the same transport but by design don't share any inheritance or interface.
This is an opportunity to introduce simple wildcards which allow defining a transport for multiple messages grouped in one namespace.
For eg. given a bunch of messages acting as commands, queries, and events (in CQRS)
App\Message\Command\CreatePost
App\Message\Command\PublishPost
App\Message\Event\PostCreated
App\Message\Event\PostPublished
App\Message\Query\FindPost
The intention may be to send all Commands to
async
transport, Queries tosync
transport but Events to a different transport for eg.stream
- the configuration requires creating routing for at least 3 classes because none of them share inheritance or interfaces with one wildcard'*'
forasync
orsync
as these are the most numerous.With this feature managing, multiple types of transport allow us to ultimately define 3 wildcarded namespaces instead and reduce the maintenance burden at the same time and prevent using standalone
'*'
which unconsciously may be the cause of problems. The configuration using namespace wildcards will look as follows:The aim of this PR is to provide a simple solution supporting wildcards in routing to prevent using
'*'
. In future scope, matching rules may be the subject of another PR addressing improvements in the future.