8000 Add a documentation about the middlewares · symfony/symfony-docs@ef70bc0 · GitHub
[go: up one dir, main page]

Skip to content

Commit ef70bc0

Browse files
srozeweaverryan
authored andcommitted
Add a documentation about the middlewares
1 parent 3ff8cfe commit ef70bc0

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

messenger.rst

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,59 @@ your ``CommandBus`` in your services:
219219
services:
220220
App\CommandBus: ['@messenger.bus.commands']
221221
222+
Middlewares
223+
-----------
224+
225+
What happens when you dispatch a message to a message bus(es) depends on its
226+
middlewares (and their order). By default, the middlewares configured for each
227+
bus looks like this.
228+
229+
1. ``logging`` middleware. Responsible of logging the beginning and the end of the
230+
message within the bus.
231+
232+
2. _Your own middlewares__
233+
234+
3. ``route_messages`` middleware. Will route the messages your configured to their
235+
corresponding sender and stop the middleware chain.
236+
237+
4. ``call_message_handler`` middleware. Will call the message handler(s) for the
238+
given message.
239+
240+
Adding your own middlewares
241+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
242+
243+
As described in the component documentation, you can add your own middlewares
244+
within the buses to add some extra capabilities like this:
245+
246+
.. code-block:: yaml
247+
248+
framework:
249+
messenger:
250+
buses:
251+
default:
252+
middlewares:
253+
# Works with the FQCN if the class discovery is enabled
254+
- App\\Middleware\\MyMiddleware
255+
256+
# Or with some service name
257+
- app.middleware.yours
258+
259+
Note that if the service is abstract, then a child service will be created per bus.
260+
261+
Disabling default middlewares
262+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
263+
264+
If you don't want the default middlewares to be present on your bus, you can disable
265+
them like this:
266+
267+
.. code-block:: yaml
268+
269+
framework:
270+
messenger:
271+
buses:
272+
default:
273+
default_middlewares: false
274+
222275
Your own Transport
223276
------------------
224277

0 commit comments

Comments
 (0)
0