Skip to content

Commit 8066314

Browse files
committed
Merge branch '4.4' into 5.0
* 4.4: Middleware clarification about being called on \"receive\"
2 parents a914120 + 145f28e commit 8066314

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

components/messenger.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ Concepts
5454
For instance: logging, validating a message, starting a transaction, ...
5555
They are also responsible for calling the next middleware in the chain,
5656
which means they can tweak the envelope, by adding stamps to it or even
57-
replacing it, as well as interrupt the middleware chain.
57+
replacing it, as well as interrupt the middleware chain. Middleware are called
58+
both when a message is originally dispatched and again later when a message
59+
is received from a transport,
5860

5961
**Envelope**
6062
Messenger specific concept, it gives full flexibility inside the message bus,
@@ -168,6 +170,8 @@ Hence you can inspect the envelope content and its stamps, or add any::
168170

169171
// You could for example add another stamp.
170172
$envelope = $envelope->with(new AnotherStamp(/* ... */));
173+
} else {
174+
// Message was just originally dispatched
171175
}
172176

173177
return $stack->next()->handle($envelope, $stack);

messenger.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,6 +1286,10 @@ for each bus looks like this:
12861286
These middleware names are actually shortcuts names. The real service ids
12871287
are prefixed with ``messenger.middleware.``.
12881288

1289+
The middleware are executed when the message is dispatched but *also* again when
1290+
a message is received via the worker (for messages that were sent to a transport
1291+
to be handled asynchronously). Keep this in mind if you create your own middleware.
1292+
12891293
You can add your own middleware to this list, or completely disable the default
12901294
middleware and *only* include your own:
12911295

0 commit comments

Comments
 (0)