8000 [WIP][Messenger] Handling & Tracking Failed Messages Support by weaverryan · Pull Request #30766 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[WIP][Messenger] Handling & Tracking Failed Messages Support #30766

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

weaverryan
Copy link
Member
Q A
Branch? master
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? TODO
Fixed tickets none
License MIT
Doc PR symfony/symfony-docs#11236

Hi o/!

This is a proposal to add global "failed messages" handling to Messenger. Messages are already retried a configurable number of times. But what happens if those all fail (e.g. due to a temporary network issue with an external service)? Currently, the messages are rejecting and lost. There is an event the user can hook into, but I think we can do better.

In this system, the envelopes would be "stored" somewhere for later. There would be 3 new commands you could use to handle them:

# see all failed messages or one in more detail
bin/console messenger:failed:show
bin/console messenger:failed:show 15

# remove all or just one message
bin/console messenger:failed:remove --all
bin/console messenger:failed:remove 15

# retry all failed message or just one
bin/console messenger:failed:retry --all
bin/console messenger:failed:retry 15

The configuration would probably look like this:

framework:
    messenger:
        # ...

        failure_handler: 'doctrine://default'

Most true messaging/queuing systems (AMQP, SQS) already have a concept of a "dead letter queue/exchange", where you can configure failed messages to go to. And this is something that we can/should document using if people are interested. However, they have few practical disadvantages. First, since these are normal queues, you can "consume" them, but you can't easily see a full list of them or look at once specific one to decide if you want to retry or remove it. Second, less robust transports like Redis & Doctrine do not have dead letter exchanges/queues built in.

Cheers!

@weaverryan weaverryan mentioned this pull request Mar 29, 2019
36 tasks
@nicolas-grekas nicolas-grekas added this to the next milestone Mar 31, 2019
@weaverryan weaverryan force-pushed the failed-message-handling branch from 9590c86 to a0fd22b Compare March 31, 2019 16:09
@weaverryan
Copy link
Member Author

This PR has the "guts" of it done, but is still unfinished. What do people think about this idea? I wanted to get some validation before pushing it forward. I personally would love this, because I could "re-try" messages that truly failed, instead of losing them.

@sroze
Copy link
Contributor
sroze commented Mar 31, 2019

Indeed, we need such a mechanism so it's a big 👍 on my side. Though... I'm not convinced we should have it outside of each transport (yet?).

less robust transports like Redis & Doctrine do not have dead letter exchanges/queues built in.

So it's the responsibility of these transports to make it happen... but actually, is it true? Realistically a "dead letter queue" has nothing special, it's just another queue. Though it's permanent and nothing is listening to it. So technically speaking we have it in the Doctrine transport: we just need to use another queue value.

@weaverryan
Copy link
Member Author

This is still on my list, but if anyone wants to help me, please ping me! My schedule this week and next is not great for having a lot of time!

@weaverryan
Copy link
Member Author

Closing in favor of #30970

@weaverryan weaverryan closed this Apr 7, 2019
@weaverryan weaverryan deleted the failed-message-handling branch April 7, 2019 11:09
@nicolas-grekas nicolas-grekas modified the milestones: next, 4.3 Apr 30, 2019
@mipapo
Copy link
mipapo commented Mar 18, 2020

Hi @weaverryan - It looks to me that's it not possible to use the "native" feature of (e.g.) SQS for dead-letter queues? I really don't want to use the "failure transprt" in #30970 .
I would like to throw an own exception when handling the message (or a predefined Exception like "FailedMessageException") and the message will be put back to the the queue.
Do I miss a corresponding option?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants
0