10000 [Messenger] Update the messenger documentation by sroze · Pull Request #9727 · symfony/symfony-docs · GitHub
[go: up one dir, main page]

Skip to content

[Messenger] Update the messenger documentation #9727

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 11 commits into from
May 9, 2018
Prev Previous commit
Next Next commit
Add a documentation about the middlewares
  • Loading branch information
sroze authored and weaverryan committed May 9, 2018
commit ef70bc058af0966d30e9d430a0b2ef213409501a
53 changes: 53 additions & 0 deletions messenger.rst
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,59 @@ your ``CommandBus`` in your services:
services:
App\CommandBus: ['@messenger.bus.commands']

Middlewares
-----------

What happens when you dispatch a message to a message bus(es) depends on its
middlewares (and their order). By default, the middlewares configured for each
bus looks like this.

1. ``logging`` middleware. Responsible of logging the beginning and the end of the
message within the bus.

2. _Your own middlewares__

3. ``route_messages`` middleware. Will route the messages your configured to their
corresponding sender and stop the middleware chain.

4. ``call_message_handler`` middleware. Will call the message handler(s) for the
given message.

Adding your own middlewares
~~~~~~~~~~~~~~~~~~~~~~~~~~~

As described in the component documentation, you can add your own middlewares
within the buses to add some extra capabilities like this:

.. code-block:: yaml

framework:
messenger:
buses:
default:
middlewares:
# Works with the FQCN if the class discovery is enabled
Copy link
Contributor

Choose a reason for hiding this comment

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

Or if you just name your service after the FQCN manually. No need to mention this IMHO. It's still a service id. ^^

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed the use of the .-based service actually.

- App\\Middleware\\MyMiddleware

# Or with some service name
- app.middleware.yours

Note that if the service is abstract, then a child service will be created per bus.
Copy link
Contributor

Choose a reason for hiding this comment

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

then a different instance of service will be created per bus.? (more concrete for the user I think)


Disabling default middlewares
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

If you don't want the default middlewares to be present on your bus, you can disable
them like this:

.. code-block:: yaml

framework:
messenger:
buses:
default:
default_middlewares: false

Your own Transport
------------------

Expand Down
0