diff --git a/messenger.rst b/messenger.rst
index 5f153908971..c30f930d2f3 100644
--- a/messenger.rst
+++ b/messenger.rst
@@ -323,7 +323,7 @@ etc) instead of the object::
// src/Message/NewUserWelcomeEmail.php
namespace App\Message;
-
+
class NewUserWelcomeEmail
{
private $userId;
@@ -671,6 +671,54 @@ this is configurable for each transport:
# implements Symfony\Component\Messenger\Retry\RetryStrategyInterface
# service: null
+ .. code-block:: xml
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ .. code-block:: php
+
+ // config/packages/messenger.php
+ $container->loadFromExtension('framework', [
+ 'messenger' => [
+ 'transports' => [
+ 'async_priority_high' => [
+ 'dsn' => '%env(MESSENGER_TRANSPORT_DSN)%',
+
+ // default configuration
+ 'retry_strategy' => [
+ 'max_retries' => 3,
+ // milliseconds delay
+ 'delay' => 1000,
+ // causes the delay to be higher before each retry
+ // e.g. 1 second delay, 2 seconds, 4 seconds
+ 'multiplier' => 2,
+ 'max_delay' => 0,
+ // override all of this with a service that
+ // implements Symfony\Component\Messenger\Retry\RetryStrategyInterface
+ // 'service' => null,
+ ],
+ ],
+ ],
+ ],
+ ]);
+
Avoiding Retrying
~~~~~~~~~~~~~~~~~
@@ -702,6 +750,46 @@ be discarded. To avoid this happening, you can instead configure a ``failure_tra
failed: 'doctrine://default?queue_name=failed'
+ .. code-block:: xml
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ .. code-block:: php
+
+ // config/packages/messenger.php
+ $container->loadFromExtension('framework', [
+ 'messenger' => [
+ // after retrying, messages will be sent to the "failed" transport
+ 'failure_transport' => 'failed',
+
+ 'transports' => [
+ // ... other transports
+
+ 'failed' => [
+ 'dsn' => 'doctrine://default?queue_name=failed',
+ ],
+ ],
+ ],
+ ]);
+
In this example, if handling a message fails 3 times (default ``max_retries``),
it will then be sent to the ``failed`` transport. While you *can* use
``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.
For example, if you have an ``async_priority_normal`` transport, you could
override it in the ``test`` environment to use this transport:
-.. code-block:: yaml
+.. configuration-block::
- # config/packages/test/messenger.yaml
- framework:
- messenger:
- transports:
- async_priority_normal: 'in-memory:///'
+ .. code-block:: yaml
+
+ # config/packages/test/messenger.yaml
+ framework:
+ messenger:
+ transports:
+ async_priority_normal: 'in-memory:///'
+
+ .. code-block:: xml
+
+
+
+
+
+
+
+
+
+
+
+
+ .. code-block:: php
+
+ // config/packages/test/messenger.php
+ $container->loadFromExtension('framework', [
+ 'messenger' => [
+ 'transports' => [
+ 'async_priority_normal' => [
+ 'dsn' => 'in-memory:///',
+ ],
+ ],
+ ],
+ ]);
Then, while testing, messages will *not* be delivered to the real transport.
Even 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
dsn: # ...
serializer: messenger.transport.symfony_serializer
+ .. code-block:: xml
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ .. code-block:: php
+
+ // config/packages/messenger.php
+ $container->loadFromExtension('framework', [
+ 'messenger' => [
+ 'serializer' => [
+ 'default_serializer' => 'messenger.transport.symfony_serializer',
+ 'symfony_serializer' => [
+ 'format' => 'json',
+ 'context' => [],
+ ],
+ ],
+ 'transports' => [
+ 'async_priority_normal' => [
+ 'dsn' => // ...
+ 'serializer' => 'messenger.transport.symfony_serializer',
+ ],
+ ],
+ ],
+ ]);
+
The ``messenger.transport.symfony_serializer`` is a built-in service that uses
the :doc:`Serializer component ` and can be configured in a few ways.
If you *do* choose to use the Symfony serializer, you can control the context