@@ -43,6 +43,23 @@ Concepts
43
43
44
44
**Handler **:
45
45
Responsible for handling messages using the business logic applicable to the messages.
46
+ Handlers are called by the ``HandleMessageMiddleware `` middleware.
47
+
48
+ **Middleware **:
49
+ Man-in-the-middle classes, allowing to spy the message and its wrapper (the envelope).
50
+ Middleware have many usages: log messages, validate messages, start a transaction, ...
51
+ It can also tweak the envelope, by adding items to it, or even completely replace it
52
+ or the message inside.
53
+
54
+ **Envelope **
55
+ Messenger specific concept, it gives full flexibility inside the message bus,
56
+ by wrapping the messages into it, allowing to add useful information inside
57
+ through *envelope items *.
58
+
59
+ **Envelope items **
60
+ Piece of information you need to attach to your message: serializer context
61
+ to use for transport, markers identifying a received message or any sort of
62
+ metadata your middleware or transport layer may use.
46
63
47
64
Bus
48
65
---
@@ -53,9 +70,9 @@ middleware stack. The component comes with a set of middleware that you can use.
53
70
When using the message bus with Symfony's FrameworkBundle, the following middleware
54
71
are configured for you:
55
72
56
- #. `` LoggingMiddleware ` ` (logs the processing of your messages)
57
- #. `` SendMessageMiddleware ` ` (enables asynchronous processing)
58
- #. `` HandleMessageMiddleware `` (calls the registered handler)
73
+ #. :class: ` Symfony \\ Component \\ Messenger \\ Middleware \\ LoggingMiddleware ` (logs the processing of your messages)
74
+ #. :class: ` Symfony \\ Component \\ Messenger \\ Asynchronous \\ Middleware \\ SendMessageMiddleware ` (enables asynchronous processing)
75
+ #. :class: ` Symfony \\ Component \\ Messenger \\ Middleware \\ HandleMessageMiddleware ` (calls the registered handler(s) )
59
76
60
77
Example::
61
78
@@ -74,7 +91,7 @@ Example::
74
91
75
92
.. note ::
76
93
77
- Every middleware needs to implement the `` MiddlewareInterface ` `.
94
+ Every middleware needs to implement the :class: ` Symfony \\ Component \\ Messenger \\ Middleware \\ MiddlewareInterface `.
78
95
79
96
Handlers
80
97
--------
@@ -112,7 +129,7 @@ the ``SerializerConfiguration`` envelope::
112
129
]))
113
130
);
114
131
115
- At the moment, the Symfony Messenger has the following built-in envelopes :
132
+ At the moment, the Symfony Messenger has the following built-in envelope items :
116
133
117
134
#. :class: `Symfony\\ Component\\ Messenger\\ Transport\\ Serialization\\ SerializerConfiguration `,
118
135
to configure the serialization groups used by the transport.
@@ -151,6 +168,12 @@ The above example will forward the message to the next middleware with an additi
151
168
envelope item *if * the message has just been received (i.e. has the `ReceivedMessage ` item).
152
169
You can create your own items by implementing :class: `Symfony\\ Component\\ Messenger\\ EnvelopeAwareInterface `.
153
170
171
+ .. note ::
172
+
173
+ Any envelope item must be php serializable if going through transport using
174
+ the :class: `Symfony\\ Component\\ Messenger\\ Transport\\ Serialization\\ Serializer `
175
+ base serializer.
176
+
154
177
Transports
155
178
----------
156
179
@@ -160,7 +183,8 @@ transport will be responsible for communicating with your message broker or 3rd
160
183
Your own Sender
161
184
~~~~~~~~~~~~~~~
162
185
163
- Using the ``SenderInterface ``, you can create your own message sender.
186
+ Using the :class: `Symfony\\ Component\\ Messenger\\ Transport\\ SenderInterface `,
187
+ you can create your own message sender.
164
188
Imagine that you already have an ``ImportantAction `` message going through the
165
189
message bus and being handled by a handler. Now, you also want to send this
166
190
message as an email.
0 commit comments