Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Messenger][WIP] Show how to configure multiple buses#10016

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
Nyholm wants to merge2 commits intosymfony:masterfromNyholm:multiple-buses
Closed
Changes fromall commits
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
41 changes: 41 additions & 0 deletionsmessenger/multiple-buses.rst
View file
Open in desktop
Original file line numberDiff line numberDiff 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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

If we're mentioning that events have zero or more subscribers, we should probably mention that commands and queries have exactly one handler.


.. 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

In 4.2,default_middleware: allow_no_handlers must be used instead.

(https://github.com/symfony/symfony/blob/master/UPGRADE-4.2.md#frameworkbundle)

- messenger.middleware.validation

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

[8]ページ先頭

©2009-2025 Movatter.jp