Skip to content
Advertisement

Symfony Messenger: is it possible to not throw the exception on last retry?

We’re using Symfony Messenger, and have these transports:

JavaScript

When we send a message to the async queue, and the last retry fails with an exception, the exception is logged to the MessengerMessages table, and the exception bubbles up (goes to Sentry in our case). This is what we want.

When we send a message to the asyncLowPriority queue however, we would like failed messages to:

  • not got to the failed transport
  • not make the exception bubble up

Basically, the exception should be dropped.

Is this possible, and how?

The reason is that we’re using this queue for downloading images asynchronously, and we already log each failure in a dedicated database table in the command handler.

Advertisement

Answer

I managed to do this with a middleware:

JavaScript

It must be configured with the name of the transport and the configured max_retries of this transport:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement