@@ -43,6 +43,28 @@ 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
+ Middleware can access the message and its wrapper (the envelope) while it is
50
+ dispatched through the bus.
51
+ Literally *"the software in the middle" *, those are not about core concerns
52
+ (business logic) of an application. Instead, they are cross cutting concerns
53
+ applicable throughout the application and affecting the entire message bus.
54
+ For instance: logging, validating a message, starting a transaction, ...
55
+ They are also responsible for calling the next middleware in the chain,
56
+ which means they can tweak the envelope, by adding items to it or even
57
+ replacing it, as well as interrupt the middleware chain.
58
+
59
+ **Envelope **
60
+ Messenger specific concept, it gives full flexibility inside the message bus,
61
+ by wrapping the messages into it, allowing to add useful information inside
62
+ through *envelope items *.
63
+
64
+ **Envelope Items **
65
+ Piece of information you need to attach to your message: serializer context
66
+ to use for transport, markers identifying a received message or any sort of
67
+ metadata your middleware or transport layer may use.
46
68
47
69
Bus
48
70
---
@@ -53,9 +75,9 @@ middleware stack. The component comes with a set of middleware that you can use.
53
75
When using the message bus with Symfony's FrameworkBundle, the following middleware
54
76
are configured for you:
55
77
56
- #. `` LoggingMiddleware ` ` (logs the processing of your messages)
57
- #. `` SendMessageMiddleware ` ` (enables asynchronous processing)
58
- #. `` HandleMessageMiddleware `` (calls the registered handler)
78
+ #. :class: ` Symfony \\ Component \\ Messenger \\ Middleware \\ LoggingMiddleware ` (logs the processing of your messages)
79
+ #. :class: ` Symfony \\ Component \\ Messenger \\ Asynchronous \\ Middleware \\ SendMessageMiddleware ` (enables asynchronous processing)
80
+ #. :class: ` Symfony \\ Component \\ Messenger \\ Middleware \\ HandleMessageMiddleware ` (calls the registered handler(s) )
59
81
60
82
Example::
61
83
@@ -74,7 +96,7 @@ Example::
74
96
75
97
.. note ::
76
98
77
- Every middleware needs to implement the `` MiddlewareInterface ` `.
99
+ Every middleware needs to implement the :class: ` Symfony \\ Component \\ Messenger \\ Middleware \\ MiddlewareInterface `.
78
100
79
101
Handlers
80
102
--------
@@ -156,6 +178,12 @@ The above example will forward the message to the next middleware with an additi
156
178
stamp *if * the message has just been received (i.e. has the `ReceivedStamp ` stamp).
157
179
You can create your own items by implementing :class: `Symfony\\ Component\\ Messenger\\ Stamp\\ StampInterface `.
158
180
181
+ .. note ::
182
+
183
+ Any envelope item must be php serializable if going through transport using
184
+ the :class: `Symfony\\ Component\\ Messenger\\ Transport\\ Serialization\\ Serializer `
185
+ base serializer.
186
+
159
187
Transports
160
188
----------
161
189
@@ -165,7 +193,8 @@ transport will be responsible for communicating with your message broker or 3rd
165
193
Your own Sender
166
194
~~~~~~~~~~~~~~~
167
<
8000
code>195
168
- Using the ``SenderInterface ``, you can create your own message sender.
196
+ Using the :class: `Symfony\\ Component\\ Messenger\\ Transport\\ SenderInterface `,
197
+ you can create your own message sender.
169
198
Imagine that you already have an ``ImportantAction `` message going through the
170
199
message bus and being handled by a handler. Now, you also want to send this
171
200
message as an email.
0 commit comments