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
Comments
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 |
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. |
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. |
Ok, then maybe a mention in the docs about this config could be useful. |
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 |
Thanks @Nyholm for your insights 🙏 |
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
The text was updated successfully, but these errors were encountered: