8000 Added configuration for multiple buses · symfony/symfony-docs@9973d67 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9973d67

Browse files
Nyholmogizanagi
authored andcommitted
Added configuration for multiple buses
1 parent 4e24dbc commit 9973d67

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

messenger/multiple-buses.rst

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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

0 commit comments

Comments
 (0)
0