Skip to content

Commit 3fb973c

Browse files
committed
Update based on comments
1 parent 509e149 commit 3fb973c

File tree

2 files changed

+30
-31
lines changed

2 files changed

+30
-31
lines changed

components/messenger.rst

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ Bus
3939
---
4040

4141
The bus is used to dispatch messages. The behaviour of the bus is in its ordered
42-
middleware stack. The component comes with a set of middlewares that you can use.
42+
middleware stack. The component comes with a set of middleware that you can use.
4343

44-
When using the message bus with Symfony's FrameworkBundle, the following middlewares
44+
When using the message bus with Symfony's FrameworkBundle, the following middleware
4545
are configured for you:
4646

47-
#. :code:`LoggingMiddleware` (logs the processing of your messages)
48-
#. :code:`SendMessageMiddleware` (enables asynchronous processing)
49-
#. :code:`HandleMessageMiddleware` (calls the registered handle)
47+
#. ``LoggingMiddleware`` (logs the processing of your messages)
48+
#. ``SendMessageMiddleware`` (enables asynchronous processing)
49+
#. ``HandleMessageMiddleware`` (calls the registered handle)
5050

5151
Example::
5252

@@ -65,7 +65,7 @@ Example::
6565

6666
.. note:
6767
68-
Every middleware need to implement the :code:`MiddlewareInterface` interface.
68+
Every middleware need to implement the ``MiddlewareInterface`` interface.
6969
7070
Handlers
7171
--------
@@ -183,7 +183,7 @@ Same bus received and sender
183183
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
184184

185185
To allow us to receive and send messages on the same bus and prevent an infinite
186-
loop, the message bus is equipped with the :code:`WrapIntoReceivedMessage` middleware.
187-
It will wrap the received messages into :code:`ReceivedMessage` objects and the
188-
:code:`SendMessageMiddleware` middleware will know it should not route these
186+
loop, the message bus is equipped with the ``WrapIntoReceivedMessage`` middleware.
187+
It will wrap the received messages into ``ReceivedMessage`` objects and the
188+
``SendMessageMiddleware`` middleware will know it should not route these
189189
messages again to an adapter.

messenger.rst

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ install messenger before using it:
2222
Using the Messenger Service
2323
---------------------------
2424

25-
Once enabled, the :code:`message_bus` service can be injected in any service where
25+
Once enabled, the ``message_bus`` service can be injected in any service where
2626
you need it, like in a controller::
2727

2828
// src/Controller/DefaultController.php
@@ -33,9 +33,9 @@ you need it, like in a controller::
3333

3434
class DefaultController extends Controller
3535
{
36-
public function indexAction(MessageBusInterface $bus)
36+
public function index(MessageBusInterface $bus)
3737
{
38-
$bus->dispatch(new MyMessage());
38+
$bus->dispatch(new SendNotification('A string to be sent...'));
3939
}
4040
}
4141

@@ -97,21 +97,21 @@ the messenger component, the following configuration should have been created:
9797
9898
# .env
9999
###> symfony/messenger ###
100-
AMQP_DSN=amqp://guest:guest@localhost:5672/%2f/messages
100+
MESSENGER_DSN=amqp://guest:guest@localhost:5672/%2f/messages
101101
###< symfony/messenger ###
102102
103-
This is enough to allow you to route your message to the :code:`messenger.default_adapter`
103+
This is enough to allow you to route your message to the ``messenger.default_adapter``
104104
adapter. This will also configure the following for you:
105105

106-
1. A :code:`messenger.default_sender` sender to be used when routing messages
107-
2. A :code:`messenger.default_receiver` receiver to be used when consuming messages.
106+
1. A ``messenger.default_sender`` sender to be used when routing messages
107+
2. A ``messenger.default_receiver`` receiver to be used when consuming messages.
108108

109109
Routing
110110
-------
111111

112112
Instead of calling a handler, you have the option to route your message(s) to a
113113
sender. Part of an adapter, it is responsible of sending your message somewhere.
114-
You can configuration which message is routed to which sender with the following
114+
You can configure which message is routed to which sender with the following
115115
configuration:
116116

117117
.. code-block:: yaml
@@ -121,9 +121,8 @@ configuration:
121121
routing:
122122
'My\Message\Message': messenger.default_sender # Or another sender service name
123123
124-
Such configuration would only route the ``MessageAboutDoingOperationalWork``
125-
message to be asynchronous, the rest of the messages would still be directly
126-
handled.
124+
Such configuration would only route the ``My\Message\Message`` message to be
125+
asynchronous, the rest of the messages would still be directly handled.
127126

128127
If you want to do route all the messages to a queue by default, you can use such
129128
configuration:
@@ -146,7 +145,7 @@ Note that you can also route a message to multiple senders at the same time:
146145
'My\Message\ToBeSentToTwoSenders': [messenger.default_sender, messenger.audit_sender]
147146
148147
Last but not least you can also route a message while still calling the handler
149-
on your application by having a :code:`null` sender:
148+
on your application by having a ``null`` sender:
150149

151150
.. code-block:: yaml
152151
@@ -159,23 +158,23 @@ Consuming messages
159158
------------------
160159

161160
Once your messages have been routed, you will like to consume your messages in most
162-
of the cases. Do to so, you can use the :code:`messenger:consume-messages` command
161+
of the cases. Do to so, you can use the ``messenger:consume-messages`` command
163162
like this:
164163

165164
.. code-block:: terminal
166165
167166
$ bin/console messenger:consume-messages messenger.default_receiver
168167
169168
The first argument is the receiver's service name. It might have been created by
170-
your :code:`adapters` configuration or it can be your own receiver.
169+
your ``adapters`` configuration or it can be your own receiver.
171170

172-
Registering your middlewares
173-
----------------------------
171+
Registering your middleware
172+
---------------------------
174173

175-
The message bus is based on middlewares. If you are un-familiar with the concept,
174+
The message bus is based on a set of middleware. If you are un-familiar with the concept,
176175
look at the :doc:`Messenger component docs </components/messenger>`.
177176

178-
To register your middleware, use the :code:`messenger.middleware` tag as in the
177+
To register your middleware, use the ``messenger.middleware`` tag as in the
179178
following example:
180179

181180
.. code-block:: xml
@@ -213,7 +212,7 @@ DSN. You will need an adapter factory::
213212
}
214213
}
215214

216-
The :code:`YourAdaper` class need to implements the :code:`AdapterInterface`. It
215+
The ``YourAdaper`` class need to implement the ``AdapterInterface``. It
217216
will like the following example::
218217

219218
use Symfony\Component\Messenger\Adapter\Factory\AdapterInterface;
@@ -245,7 +244,7 @@ Register your factory
245244
Use your adapter
246245
~~~~~~~~~~~~~~~~
247246

248-
Within the :code:`framework.messenger.adapters.*` configuration, create your
247+
Within the ``framework.messenger.adapters.*`` configuration, create your
249248
named adapter using your own DSN:
250249

251250
.. code-block:: yaml
@@ -257,8 +256,8 @@ named adapter using your own DSN:
257256
258257
This will give you access to the following services:
259258

260-
1. :code:`messenger.yours_adapter`: the instance of your adapter.
261-
2. :code:`messenger.yours_receiver` and :code:`messenger.yours_sender`, the
259+
1. ``messenger.yours_adapter``: the instance of your adapter.
260+
2. ``messenger.yours_receiver`` and ``messenger.yours_sender``, the
262261
receiver and sender created by the adapter.
263262

264263
.. _`enqueue's adapter`: https://github.com/sroze/enqueue-bridge

0 commit comments

Comments
 (0)