@@ -323,7 +323,7 @@ etc) instead of the object::
323323
324324 // src/Message/NewUserWelcomeEmail.php
325325 namespace App\Message;
326-
326+
327327 class NewUserWelcomeEmail
328328 {
329329 private $userId;
@@ -671,6 +671,54 @@ this is configurable for each transport:
671671# implements Symfony\Component\Messenger\Retry\RetryStrategyInterface
672672# service: null
673673
674+ ..code-block ::xml
675+
676+ <!-- config/packages/messenger.xml-->
677+ <?xml version =" 1.0" encoding =" UTF-8" ?>
678+ <container xmlns =" http://symfony.com/schema/dic/services"
679+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
680+ xmlns : framework =" http://symfony.com/schema/dic/symfony"
681+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
682+ https://symfony.com/schema/dic/services/services-1.0.xsd
683+ http://symfony.com/schema/dic/symfony
684+ https://symfony.com/schema/dic/symfony/symfony-1.0.xsd" >
685+
686+ <framework : config >
687+ <framework : messenger >
688+ <framework : transport name =" async_priority_high" dsn =" %env(MESSENGER_TRANSPORT_DSN)%?queue_name=high_priority" >
689+ <framework : retry-strategy max-retries =" 3" delay =" 1000" multiplier =" 2" max-delay =" 0" />
690+ </framework : transport >
691+ </framework : messenger >
692+ </framework : config >
693+ </container >
694+
695+ ..code-block ::php
696+
697+ // config/packages/messenger.php
698+ $container->loadFromExtension('framework', [
699+ 'messenger' => [
700+ 'transports' => [
701+ 'async_priority_high' => [
702+ 'dsn' => '%env(MESSENGER_TRANSPORT_DSN)%',
703+
704+ // default configuration
705+ 'retry_strategy' => [
706+ 'max_retries' => 3,
707+ // milliseconds delay
708+ 'delay' => 1000,
709+ // causes the delay to be higher before each retry
710+ // e.g. 1 second delay, 2 seconds, 4 seconds
711+ 'multiplier' => 2,
712+ 'max_delay' => 0,
713+ // override all of this with a service that
714+ // implements Symfony\Component\Messenger\Retry\RetryStrategyInterface
715+ // 'service' => null,
716+ ],
717+ ],
718+ ],
719+ ],
720+ ]);
721+
674722 Avoiding Retrying
675723~~~~~~~~~~~~~~~~~
676724
@@ -702,6 +750,46 @@ be discarded. To avoid this happening, you can instead configure a ``failure_tra
702750
703751failed :' doctrine://default?queue_name=failed'
704752
753+ ..code-block ::xml
754+
755+ <!-- config/packages/messenger.xml-->
756+ <?xml version =" 1.0" encoding =" UTF-8" ?>
757+ <container xmlns =" http://symfony.com/schema/dic/services"
758+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
759+ xmlns : framework =" http://symfony.com/schema/dic/symfony"
760+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
761+ https://symfony.com/schema/dic/services/services-1.0.xsd
762+ http://symfony.com/schema/dic/symfony
763+ https://symfony.com/schema/dic/symfony/symfony-1.0.xsd" >
764+
765+ <framework : config >
766+ <!-- after retrying, messages will be sent to the "failed" transport-->
767+ <framework : messenger failure-transport =" failed" >
768+ <!-- ... other transports-->
769+
770+ <framework : transport name =" failed" dsn =" doctrine://default?queue_name=failed" />
771+ </framework : messenger >
772+ </framework : config >
773+ </container >
774+
775+ ..code-block ::php
776+
777+ // config/packages/messenger.php
778+ $container->loadFromExtension('framework', [
779+ 'messenger' => [
780+ // after retrying, messages will be sent to the "failed" transport
781+ 'failure_transport' => 'failed',
782+
783+ 'transports' => [
784+ // ... other transports
785+
786+ 'failed' => [
787+ 'dsn' => 'doctrine://default?queue_name=failed',
788+ ],
789+ ],
790+ ],
791+ ]);
792+
705793 In this example, if handling a message fails 3 times (default ``max_retries ``),
706794it will then be sent to the ``failed `` transport. While you *can * use
707795``messenger:consume failed `` to consume this like a normal transport, you'll
@@ -947,13 +1035,47 @@ holds them in memory during the request, which can be useful for testing.
9471035For example, if you have an ``async_priority_normal `` transport, you could
9481036override it in the ``test `` environment to use this transport:
9491037
950- ..code-block ::yaml
1038+ ..configuration-block ::
1039+
1040+ ..code-block ::yaml
1041+
1042+ # config/packages/test/messenger.yaml
1043+ framework :
1044+ messenger :
1045+ transports :
1046+ async_priority_normal :' in-memory:///'
1047+
1048+ ..code-block ::xml
1049+
1050+ <!-- config/packages/messenger.xml-->
1051+ <?xml version =" 1.0" encoding =" UTF-8" ?>
1052+ <container xmlns =" http://symfony.com/schema/dic/services"
1053+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
1054+ xmlns : framework =" http://symfony.com/schema/dic/symfony"
1055+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
1056+ https://symfony.com/schema/dic/services/services-1.0.xsd
1057+ http://symfony.com/schema/dic/symfony
1058+ https://symfony.com/schema/dic/symfony/symfony-1.0.xsd" >
9511059
952- # config/packages/test/messenger.yaml
953- framework :
954- messenger :
955- transports :
956- async_priority_normal :' in-memory:///'
1060+ <framework : config >
1061+ <framework : messenger >
1062+ <framework : transport name =" async_priority_normal" dsn =" in-memory:///" />
1063+ </framework : messenger >
1064+ </framework : config >
1065+ </container >
1066+
1067+ ..code-block ::php
1068+
1069+ // config/packages/messenger.php
1070+ $container->loadFromExtension('framework', [
1071+ 'messenger' => [
1072+ 'transports' => [
1073+ 'async_priority_normal' => [
1074+ 'dsn' => 'in-memory:///',
1075+ ],
1076+ ],
1077+ ],
1078+ ]);
9571079
9581080 Then, while testing, messages will *not * be delivered to the real transport.
9591081Even better, in a test, you can check that exactly one message was sent
@@ -1020,6 +1142,52 @@ this globally (or for each transport) to a service that implements
10201142dsn :# ...
10211143serializer :messenger.transport.symfony_serializer
10221144
1145+ ..code-block ::xml
1146+
1147+ <!-- config/packages/messenger.xml-->
1148+ <?xml version =" 1.0" encoding =" UTF-8" ?>
1149+ <container xmlns =" http://symfony.com/schema/dic/services"
1150+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
1151+ xmlns : framework =" http://symfony.com/schema/dic/symfony"
1152+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
1153+ https://symfony.com/schema/dic/services/services-1.0.xsd
1154+ http://symfony.com/schema/dic/symfony
1155+ https://symfony.com/schema/dic/symfony/symfony-1.0.xsd" >
1156+
1157+ <framework : config >
1158+ <framework : messenger >
1159+ <framework : serializer default-serializer =" messenger.transport.symfony_serializer" >
1160+ <framework : symfony-serializer format =" json" >
1161+ <framework : context />
1162+ </framework : symfony-serializer >
1163+ </framework : serializer >
1164+
1165+ <framework : transport name =" async_priority_normal" dsn =" ..." serializer =" messenger.transport.symfony_serializer" />
1166+ </framework : messenger >
1167+ </framework : config >
1168+ </container >
1169+
1170+ ..code-block ::php
1171+
1172+ // config/packages/messenger.php
1173+ $container->loadFromExtension('framework', [
1174+ 'messenger' => [
1175+ 'serializer' => [
1176+ 'default_serializer' => 'messenger.transport.symfony_serializer',
1177+ 'symfony_serializer' => [
1178+ 'format' => 'json',
1179+ 'context' => [],
1180+ ],
1181+ ],
1182+ 'transports' => [
1183+ 'async_priority_normal' => [
1184+ 'dsn' => // ...
1185+ 'serializer' => 'messenger.transport.symfony_serializer',
1186+ ],
1187+ ],
1188+ ],
1189+ ]);
1190+
10231191 The ``messenger.transport.symfony_serializer `` is a built-in service that uses
10241192the:doc: `Serializer component </serializer >` and can be configured in a few ways.
10251193If you *do * choose to use the Symfony serializer, you can control the context