-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
Changes from 1 commit
585491d
b40bc71
b26de80
88ba8fe
5c828e4
31a56ee
2493c90
bcfae23
25c0b6e
a15752b
fb88abc
509e149
3fb973c
32403ea
c5306b8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
are configured for you: | ||
|
||
#. :code:`LoggingMiddleware` (logs the processing of your messages) | ||
#. :code:`SendMessageMiddleware` (enables asynchronous processing) | ||
|
@@ -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 | ||
-------- | ||
|
||
|
@@ -87,11 +93,8 @@ Adapters | |
The communication with queuing system or third parties is delegated to | ||
libraries for now. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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" |
||
|
@@ -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. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,7 +93,7 @@ the messenger component, the following configuration should have been created: | |
adapters: | ||
default: "%env(MESSENGER_DSN)%" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here the env var is called |
||
|
||
.. code-block:: env | ||
.. code-block:: bash | ||
|
||
# .env | ||
###> symfony/messenger ### | ||
|
@@ -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"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about |
||
<tag name="messenger.middleware" /> | ||
</service> | ||
|
||
Your own Adapters | ||
----------------- | ||
|
||
|
There was a problem hiding this comment.
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 :)