New in Symfony 4.3: Messenger failure transport
May 3, 2019 • Published by Javier Eguiluz
Warning: This post is about an unsupported Symfony version. Some of this information may be out of date. Read the most recent Symfony Docs.
The Messenger component provides a retry mechanism for messages. In Symfony 4.3 we've improved this feature to add a "failure" transport, so that messages that fail on all their retries can be collected in one spot and retried later if wanted.
Consider the following configuration:
1 2 3 4 5 6 7 8 9 10 11 12
framework:
messenger:
failure_transport: failed
transports:
async:
dsn: 'amqp://'
failed:
dsn: 'doctrine://default?queue_name=failed'
routing:
'App\Message\SmsNotification': async
In this setup, SmsNotification
would be retried three times on the async
transport and then finally sent to the failed
transport. You can consume the
failed
transport like a normal transport, but you should handle and consume
it by one of these new commands:
1 2 3 4 5 6 7 8 9 10 11 12 13
$ php bin/console messenger:failed:show
There are 3 messages waiting in the failed transport.
--- --------------------------- ------------------- -----
Id Class Failed at Error
--- --------------------------- ------------------- -----
217 App\Message\SmsNotification 2019-04-10 22:12:01 ...
218 App\Message\SmsNotification 2019-04-10 22:12:00 ...
219 App\Message\SmsNotification 2019-04-10 22:11:59 ...
--- --------------------------- ------------------- -----
// Run "messenger:failed:show {id} -vv" to see message details
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
$ php bin/console messenger:failed:show 217
There are 3 messages waiting in the failed transport.
----------- ---------------------------
Class App\Message\SmsNotification
Message Id 217
Failed at 2019-04-10 22:12:01
Error ...
Error Class Exception
Transport async
----------- ---------------------------
Re-run command with "-vv" to see more message & error details.
Run "messenger:failed:retry 217" to retry this message.
Run "messenger:failed:purge 217" to delete it.
Help the Symfony project!
As with any Open-Source project, contributing code or documentation is the most common way to help, but we also have a wide range of sponsoring opportunities.
Comments are closed.
To ensure that comments stay relevant, they are closed for old posts.
dsn: 'doctrine://default?queue_name=failed'
I'm not familiar with this syntax for doctrine.
https://github.com/symfony/symfony-docs/pull/10616/files
btw, ^ (the above comment): is it related to Symfony?