问题描述
有没有办法禁用 ActiveJob 和 Sidekiq 的自动重试?
Is there a way to disable automatic retry with ActiveJob and Sidekiq ?
我知道只有使用 Sidekiq,我们只需要把
I know that with Sidekiq only, we just have to put
sidekiq_options :retry => false
正如这里提到的:https://github.com/mperham/sidekiq/wiki/错误处理#configuration
但它似乎不适用于 ActiveJob 和 Sidekiq.
but it doesn't seem to work with ActiveJob and Sidekiq.
我也知道这里提出的完全禁用重试的解决方案:https://stackoverflow.com/a/28216822/2431728
I also know the solution to entierly disable the retry as proposed here : https://stackoverflow.com/a/28216822/2431728
但这不是我需要的行为.
But it's not the behavior I need.
推荐答案
好的,谢谢您的回答.
仅供参考,我还在 ActiveJob Github 存储库上与此主题相关的问题中提出了问题:https://github.com/rails/activejob/issues/47
Just for information, I also asked the question in an issue related to this subject on ActiveJob Github repository : https://github.com/rails/activejob/issues/47
DHH 回答了我一个我没有测试过但可以完成工作的解决方案.
DHH answered me a solution I haven't tested but that can do the job.
就个人而言,我最终将其放入初始化程序中,以便全局禁用 Sidekiq 重试,并且效果很好:
Personnally, I finally put this in an initializer in order to disable Sidekiq retries globally and it works well :
Sidekiq.configure_server do |config|
config.server_middleware do |chain|
chain.add Sidekiq::Middleware::Server::RetryJobs, :max_retries => 0
end
end
这篇关于禁用 ActiveJob 自动重试,与 Sidekiq 一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!