Retrying Failed Messages In A Symfony Application

How To Retry

Messenger Component, retries a failed message through the dead letter feature of RabbitMQ in case of RabbitMQ usage. It tries by default 3 times, with 1000 ms delay, and multiplies the duration by 2 in each try.

How To Customize Retry Strategy:

Messenger Component, allows you to customize the retry strategy, based on the transporters. You can customize the retry strategy of your transporter as following:

How To Avoid Retrying

You may have some specific scenarios that you should ignore a failed message. In this case, you can simply throw Symfony\Component\Messenger\Exception\UnrecoverableMessageHandlingException. In case of you throw this exception, you will see that Messenger won’t create the dead letter queues on RabbitMQ and will never retry that failed message.

How To Save Failed Messages

Normally, a failed message will be discarded after retried several times. You can avoid this situation by using failure_transport configuration. When you configured a specific transporter for the failure case, Messenger will store send the message to the failure transporter, after it retried several times.

$ ./bin/console messenger:consume failed --time-limit=3600 --memory-limit=128M

Previous Article:

Using RabbitMQ in A Symfony Application Through Messenger Component

Just another software developer Github: Linkedin:

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store