Skip to content
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

[Messenger] Option to never remove a message from a transport #38497

Closed
arjanfrans opened this issue Oct 9, 2020 · 6 comments
Closed

[Messenger] Option to never remove a message from a transport #38497

arjanfrans opened this issue Oct 9, 2020 · 6 comments

Comments

@arjanfrans
Copy link

arjanfrans commented Oct 9, 2020

Description
As far as I understand a 'max_retries' is always set. What I want to achieve is that any messsages that land in the 'failed' transport will not have a 'max_retries'.

My use case is that during development, or finding problems on a production system, I need to debug messages. Messages can fail due to a problem in the code. After fixing the problem in the code, I want to retry a message and see if it works again. However, I can only retry 3 times (at least with the default setup). As a workaround I can set the 'max_retries' value a high number. But it would be nice if I just could disable 'max_retries', which having to write a custom retry strategy.

Currently my workflow of dealing failed messages is manually retrying them, mostly one-by-one to be sure. I am wondering if anyone else has a use case for disabling the 'max_retries' limit?

Example

framework:
    messenger:
        failure_transport: failed

        transports:
            async:
                dsn: '%env(MESSENGER_TRANSPORT_DSN)%'
                retry_strategy:
                    max_retries: 3
                    delay: 1000
                    multiplier: 2
                    max_delay: 0

            failed:
                dsn: '%env(MESSENGER_TRANSPORT_DSN)%'
                retry_strategy:
                    disable_max_retries: true # <---------------------------------
                options:
                    queue_name: failed
@Nyholm
Copy link
Member

Nyholm commented Oct 9, 2020

Just an FYI:

You can do something like this:

class MyStrategy implements RetryStrategyInterface
    public function isRetryable(Envelope $message, \Throwable $throwable = null): bool
    {
        return true;
    }
    public function getWaitingTime(Envelope $message, \Throwable $throwable = null): int
    {
        return 1000;
    }
}
            failed:
                dsn: '%env(MESSENGER_TRANSPORT_DSN)%'
                retry_strategy:
-                    disable_max_retries: true # <---------------------------------
+                    service: 'App\MyStrategy'

That would efficiently disable that messages are removed. And as you mentioned, you could also do:

            failed:
                dsn: '%env(MESSENGER_TRANSPORT_DSN)%'
                retry_strategy:
                    max_retries: 30

With the default settings and (no max_delay), this would retry your code for 34 years... =)

            failed:
                dsn: '%env(MESSENGER_TRANSPORT_DSN)%'
                retry_strategy:
                    max_retries: 10000
                    max_delay: 3600

This will retry every hour for about a year.

I wrote about this here, It might be interesting to read.


I dont think disable_max_retries is needed because it is easy to add your own strategy and the existing config makes it simple to retry often and pretty much for forever.

@Aerendir
Copy link
Contributor

This seems to me a common use case. Why force someone to copy and paste the same classes in many projects to solve those common use cases and force to maintain different versions of the exactly same functionality?

Doing this seems to me like boilerplate and boilerplate should be avoided and made easier to manage.

@Nyholm
Copy link
Member

Nyholm commented Oct 11, 2020

This seems to me a common use case.

I dont really think so.

And I already showed you config that does not use insanely large numbers but you still get your messages stored for 30+ years. My two "config only" examples would very well fit the scenario you describe.

@Aerendir
Copy link
Contributor

Ok, then maybe a mention in the docs about this config could be useful.

@Nyholm
Copy link
Member

Nyholm commented Oct 11, 2020

I agree with you. Here is a part of the documentation that describes how to set these parameters: https://symfony.com/doc/current/messenger.html#retries-failures

@Nyholm Nyholm closed this as completed Oct 11, 2020
@B-Galati
Copy link
Contributor

B-Galati commented Dec 1, 2020

Thanks @Nyholm for your insights 🙏

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

No branches or pull requests

4 participants