@@ -926,7 +926,7 @@ to retry them:
926926
927927 # see all messages in the failure transport with a default limit of 50
928928 $ php bin/console messenger:failed:show
929-
929+
930930 # see the 10 first messages
931931 $ php bin/console messenger:failed:show --max=10
932932
@@ -2263,6 +2263,62 @@ of the process. For each, the event class is the event name:
22632263*:class: `Symfony\\ Component\\ Messenger\\ Event\\ WorkerRunningEvent `
22642264*:class: `Symfony\\ Component\\ Messenger\\ Event\\ WorkerStoppedEvent `
22652265
2266+ Additional Handler Arguments
2267+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2268+
2269+ It's possible to have messenger pass additional data to the message handler using the
2270+ :class: `Symfony\\ Component\\ Messenger\\ Stamp\\ HandlerArgumentsStamp `. Add this stamp to
2271+ the envelope in a middleware and fill it with any additional data you want to have
2272+ available in the handler.
2273+
2274+ // src/Library/Messenger/AdditionalArgumentMiddleware.php
2275+ namespace App\L ibrary\M essenger;
2276+
2277+ use Symfony\C omponent\M essenger\E nvelope;
2278+ use Symfony\C omponent\M essenger\M iddleware\M iddlewareInterface;
2279+ use Symfony\C omponent\M essenger\M iddleware\S tackInterface;
2280+ use Symfony\C omponent\M essenger\S tamp\H andlerArgumentsStamp;
2281+
2282+ class AdditionalArgumentMiddleware implements MiddlewareInterface
2283+ {
2284+ public function handle(Envelope $envelope, StackInterface $stack): Envelope
2285+ {
2286+ $envelope = $envelope->with(
2287+ new HandlerArgumentsStamp(
2288+ [
2289+ $this->resolveAdditionalArgument($envelope->getMessage()),
2290+ ],
2291+ ),
2292+ )
2293+
2294+ return $stack->next()->handle($envelope, $stack);
2295+ }
2296+
2297+ private function resolveAdditionalArgument(object $message): mixed
2298+ {
2299+ // ...
2300+ }
2301+ }
2302+
2303+ Then your handler will look like this:
2304+
2305+ // src/MessageHandler/SmsNotificationHandler.php
2306+ namespace App\M essageHandler;
2307+
2308+ use App\M essage\S msNotification;
2309+
2310+ class SmsNotificationHandler
2311+ {
2312+ public function __invoke(SmsNotification $message, mixed $additionalArgument)
2313+ {
2314+ // ...
2315+ }
2316+ }
2317+
2318+ ..versionadded ::6.2
2319+
2320+ The HandlerArgumentsStamp was introduced in Symfony 6.2.
2321+
22662322Multiple Buses, Command & Event Buses
22672323-------------------------------------
22682324