@@ -22,7 +22,7 @@ install messenger before using it:
22
22
Using the Messenger Service
23
23
---------------------------
24
24
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
26
26
you need it, like in a controller::
27
27
28
28
// src/Controller/DefaultController.php
@@ -33,9 +33,9 @@ you need it, like in a controller::
33
33
34
34
class DefaultController extends Controller
35
35
{
36
- public function indexAction (MessageBusInterface $bus)
36
+ public function index (MessageBusInterface $bus)
37
37
{
38
- $bus->dispatch(new MyMessage( ));
38
+ $bus->dispatch(new SendNotification('A string to be sent...' ));
39
39
}
40
40
}
41
41
@@ -97,21 +97,21 @@ the messenger component, the following configuration should have been created:
97
97
98
98
# .env
99
99
# ##> symfony/messenger ###
100
- AMQP_DSN =amqp://guest:guest@localhost:5672/%2f/messages
100
+ MESSENGER_DSN =amqp://guest:guest@localhost:5672/%2f/messages
101
101
# ##< symfony/messenger ###
102
102
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 ` `
104
104
adapter. This will also configure the following for you:
105
105
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.
108
108
109
109
Routing
110
110
-------
111
111
112
112
Instead of calling a handler, you have the option to route your message(s) to a
113
113
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
115
115
configuration:
116
116
117
117
.. code-block :: yaml
@@ -121,9 +121,8 @@ configuration:
121
121
routing :
122
122
' My\Message\Message ' : messenger.default_sender # Or another sender service name
123
123
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.
127
126
128
127
If you want to do route all the messages to a queue by default, you can use such
129
128
configuration:
@@ -146,7 +145,7 @@ Note that you can also route a message to multiple senders at the same time:
146
145
' My\Message\ToBeSentToTwoSenders ' : [messenger.default_sender, messenger.audit_sender]
147
146
148
147
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:
150
149
151
150
.. code-block :: yaml
152
151
@@ -159,23 +158,23 @@ Consuming messages
159
158
------------------
160
159
161
160
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
163
162
like this:
164
163
165
164
.. code-block :: terminal
166
165
167
166
$ bin/console messenger:consume-messages messenger.default_receiver
168
167
169
168
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.
171
170
172
- Registering your middlewares
173
- ----------------------------
171
+ Registering your middleware
172
+ ---------------------------
174
173
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,
176
175
look at the :doc: `Messenger component docs </components/messenger >`.
177
176
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
179
178
following example:
180
179
181
180
.. code-block :: xml
@@ -213,7 +212,7 @@ DSN. You will need an adapter factory::
213
212
}
214
213
}
215
214
216
- The :code: ` YourAdaper ` class need to implements the :code: ` AdapterInterface `. It
215
+ The `` YourAdaper `` class need to implement the `` AdapterInterface ` `. It
217
216
will like the following example::
218
217
219
218
use Symfony\Component\Messenger\Adapter\Factory\AdapterInterface;
@@ -245,7 +244,7 @@ Register your factory
245
244
Use your adapter
246
245
~~~~~~~~~~~~~~~~
247
246
248
- Within the :code: ` framework.messenger.adapters.* ` configuration, create your
247
+ Within the `` framework.messenger.adapters.* ` ` configuration, create your
249
248
named adapter using your own DSN:
250
249
251
250
.. code-block :: yaml
@@ -257,8 +256,8 @@ named adapter using your own DSN:
257
256
258
257
This will give you access to the following services:
259
258
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
262
261
receiver and sender created by the adapter.
263
262
264
263
.. _`enqueue's adapter` : https://github.com/sroze/enqueue-bridge
0 commit comments