8000 [Messenger] Multiples buses, scoping handlers per bus, PSR-4 discovery & debug by ogizanagi · Pull Request #10689 · symfony/symfony-docs · GitHub
[go: up one dir, main page]

Skip to content

[Messenger] Multiples buses, scoping handlers per bus, PSR-4 discovery & debug #10689

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

Merged
merged 2 commits into from
Dec 27, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Added configuration for multiple buses
  • Loading branch information
Nyholm authored and ogizanagi committed Nov 28, 2018
commit 9973d671bfe44791ef125fb2342a7c1c9e7b9ef1
41 changes: 41 additions & 0 deletions messenger/multiple-buses.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
.. index::
single: Messenger; Multiple buses

Multiple Buses
==============

A common architecture when building application is to separate commands from
queries. Commands are actions that do something and queries fetches data. This
is called CQRS (Command Query Responsibility Segregation). See Martin Fowler's
`article about CQRS`_ to learn more. This architecture could be used together
with the messenger component by defining multiple buses.

A **command bus** is a little different form a **query bus**. As example,
command buses must not return anything and query buses are rarely asynchronous.
You can configure these buses and their rules by using middlewares.

It might also be a good idea to separate actions from reactions by introducing
an **event bus**. The event bus could have zero or more subscribers.

.. configuration-block::

.. code-block:: yaml

framework:
messenger:
default_bus: messenger.bus.command
buses:
messenger.bus.command:
middleware:
- messenger.middleware.validation
- messenger.middleware.handles_recorded_messages: ['@messenger.bus.event']
- doctrine_transaction_middleware: ['default']
messenger.bus.query:
middleware:
- messenger.middleware.validation
messenger.bus.event:
middleware:
- messenger.middleware.allow_no_handler
- messenger.middleware.validation

.. _article about CQRS: https://martinfowler.com/bliki/CQRS.html
0