File tree Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change 1+ .. index ::
2+ single: Messenger; Multiple buses
3+
4+ Multiple Buses
5+ ==============
6+
7+ A common architecture when building application is to separate commands from
8+ queries. Commands are actions that do something and queries fetches data. This
9+ is called CQRS (Command Query Responsibility Segregation). See Martin Fowler's
10+ `article about CQRS `_ to learn more. This architecture could be used together
11+ with the messenger component by defining multiple buses.
12+
13+ A **command bus ** is a little different form a **query bus **. As example,
14+ command buses must not return anything and query buses are rarely asynchronous.
15+ You can configure these buses and their rules by using middlewares.
16+
17+ It might also be a good idea to separate actions from reactions by introducing
18+ an **event bus **. The event bus could have zero or more subscribers.
19+
20+ .. configuration-block ::
21+
22+ .. code-block :: yaml
23+
24+ framework :
25+ messenger :
26+ default_bus : messenger.bus.command
27+ buses :
28+ messenger.bus.command :
29+ middleware :
30+ - messenger.middleware.validation
31+ - messenger.middleware.handles_recorded_messages : ['@messenger.bus.event']
32+ - doctrine_transaction_middleware : ['default']
33+ messenger.bus.query :
34+ middleware :
35+ - messenger.middleware.validation
36+ messenger.bus.event :
37+ middleware :
38+ - messenger.middleware.allow_no_handler
39+ - messenger.middleware.validation
40+
41+ .. _article about CQRS : https://martinfowler.com/bliki/CQRS.html
You can’t perform that action at this time.
0 commit comments