8000 Symfony Messenger component documentation by sroze · Pull Request #9437 · symfony/symfony-docs · GitHub
[go: up one dir, main page]

Skip to content

Symfony Messenger component documentation #9437

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 15 commits into from
Apr 16, 2018
Merged
Show file tree
Hide file tree
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
Prev Previous commit
Next Next commit
Add a documentation about middlewares and update based on reviews
  • Loading branch information
sroze committed Mar 27, 2018
commit 509e1494af904a4c79fb73936d2062c55b9361ee
21 changes: 12 additions & 9 deletions components/messenger.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@ Concepts
Bus
---

The bus is used to dispatch messages. MessageBus' behaviour is in its ordered
middleware stack. When using the message bus with Symfony's FrameworkBundle, the
following middlewares are configured for you:
The bus is used to dispatch messages. The behaviour of the bus is in its ordered
middleware stack. The component comes with a set of middlewares that you can use.

When using the message bus with Symfony's FrameworkBundle, the following middlewares
Copy link
Member

Choose a reason for hiding this comment

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

middleware is uncountable in English, so no plural for it :)

are configured for you:

#. :code:`LoggingMiddleware` (logs the processing of your messages)
#. :code:`SendMessageMiddleware` (enables asynchronous processing)
Expand All @@ -56,11 +58,15 @@ Example::
$bus = new MessageBus([
new HandleMessageMiddleware(new HandlerLocator([
MyMessage::class => $handler,
]))
])),
]);

$result = $bus->handle(new MyMessage(/* ... */));

.. note:

Every middleware need to implement the :code:`MiddlewareInterface` interface.

Handlers
--------

Expand All @@ -87,11 +93,8 @@ Adapters
The communication with queuing system or third parties is delegated to
libraries for now.
Copy link

Choose a reason for hiding this comment

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

It isn't at all clear what this means or what are the implications for someone who intends to communicate with a queuing system or third party. Also system -> systems. And drop "for now" unless you want to say something about what will happen in the future.


Create your adapter
~~~~~~~~~~~~~~~~~~~

Your own sender
---------------
~~~~~~~~~~~~~~~

Using the ``SenderInterface``, you can easily create your own message sender.
Let's say you already have an ``ImportantAction`` message going through the
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure what Symfony's policy is on this but I refrain to use elision in docs and would write "Let us say"

Expand Down Expand Up @@ -134,7 +137,7 @@ First, create your sender::
}

Your own receiver
-----------------
~~~~~~~~~~~~~~~~~

A receiver is responsible for receiving messages from a source and dispatching
them to the application.
Expand Down
17 changes: 16 additions & 1 deletion messenger.rst
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ the messenger component, the following configuration should have been created:
adapters:
default: "%env(MESSENGER_DSN)%"
Copy link
Member

Choose a reason for hiding this comment

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

Here the env var is called MESSENGER_DSN but below is AMQP_DSN


.. code-block:: env
.. code-block:: bash

# .env
###> symfony/messenger ###
Expand Down Expand Up @@ -169,6 +169,21 @@ like this:
The first argument is the receiver's service name. It might have been created by
your :code:`adapters` configuration or it can be your own receiver.

Registering your middlewares
----------------------------

The message bus is based on middlewares. If you are un-familiar with the concept,
look at the :doc:`Messenger component docs </components/messenger>`.

To register your middleware, use the :code:`messenger.middleware` tag as in the
following example:

.. code-block:: xml

<service id="Your\Own\Middleware">
Copy link

Choose a reason for hiding this comment

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

How about App\Middleware.

4EAA
<tag name="messenger.middleware" />
</service>

Your own Adapters
-----------------

Expand Down
0