Skip to content

Middleware clarification about being called on "receive" #12535

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion components/messenger.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ Concepts
For instance: logging, validating a message, starting a transaction, ...
They are also responsible for calling the next middleware in the chain,
which means they can tweak the envelope, by adding stamps to it or even
replacing it, as well as interrupt the middleware chain.
replacing it, as well as interrupt the middleware chain. Middleware are called
both when a message is originally dispatched and again later when a message
is received from a tansport,

**Envelope**
Messenger specific concept, it gives full flexibility inside the message bus,
Expand Down Expand Up @@ -174,6 +176,8 @@ Hence you can inspect the envelope content and its stamps, or add any::

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

return $stack->next()->handle($envelope, $stack);
Expand Down
4 changes: 4 additions & 0 deletions messenger.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1297,6 +1297,10 @@ for each bus looks like this:
These middleware names are actually shortcuts names. The real service ids
are prefixed with ``messenger.middleware.``.

The middleware are executed when the message is dispatched but *also* again when
a message is received via the worker (for messages that were sent to a transport
to be handled asynchronously). Keep this in mind if you create your own middleware.

You can add your own middleware to this list, or completely disable the default
middleware and *only* include your own:

Expand Down