未sidekiq_retries_exhausted
被叫的原因是什么?我缺少某些设置吗?
可能有一些东西覆盖了sidekiq_options retry: 1
,并且工作人员一直在重试,但是怎么办?
class SomeWorker
include Sidekiq::Worker
sidekiq_options retry: 1
sidekiq_retries_exhausted do |msg|
# => never hit this point
Rails.logger.info "tried two times, failed"
end
def perform(_args)
raise
end
end
答案 0 :(得分:0)
问题是,通过如下代码添加作业时:
Sidekiq::Client.push(
'class' => 'SomeWorker',
'args' => [
foo: "bar",
],
)
由于某些原因,省略了类声明sidekiq_options retry: 1
中的 retries设置(错误?/是设计使然?)。相反,需要显式设置'retry' => 1
:
Sidekiq::Client.push(
'class' => 'SomeWorker',
'args' => [
foo: "bar",
],
'retry' => 1
)