Skip to content

Commit 145f28e

Browse files
committed
Merge branch '4.3' into 4.4
* 4.3: Middleware clarification about being called on \"receive\"
2 parents 2092d2a + f89f521 commit 145f28e

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,
@@ -174,6 +176,8 @@ Hence you can inspect the envelope content and its stamps, or add any::
174176

175177
// You could for example add another stamp.
176178
$envelope = $envelope->with(new AnotherStamp(/* ... */));
179+
} else {
180+
// Message was just originally dispatched
177181
}
178182

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

messenger.rst

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

1325+
The middleware are executed when the message is dispatched but *also* again when
1326+
a message is received via the worker (for messages that were sent to a transport
1327+
to be handled asynchronously). Keep this in mind if you create your own middleware.
1328+
13251329
You can add your own middleware to this list, or completely disable the default
13261330
middleware and *only* include your own:
13271331

0 commit comments

Comments
 (0)