從Rails的API,我發現ActiveJob可以retry_job間隔:如何使用ActiveJob設置Sidekiq的重試次數?
my_job_instance.enqueue
my_job_instance.enqueue wait: 5.minutes
my_job_instance.enqueue queue: :important
my_job_instance.enqueue wait_until: Date.tomorrow.midnight
但如果我想設置重試次數,如Sidekiq的:
include Sidekiq::Worker
sidekiq_options :retry => 5
如何在這個示例代碼?
class SiteScrapperJob < ActiveJob::Base
rescue_from(ErrorLoadingSite) do
retry_job queue: :low_priority
end
def perform(*args)
# raise ErrorLoadingSite if cannot scrape
end
end
現在,我已將此添加到我的作業類:
Sidekiq.default_worker_options = { retry: 5 }
但似乎不是很好。
你錯了。 '重試'可以是一個數字。 https://github.com/mperham/sidekiq/wiki/Error-Handling#configuration –
你的問題的標題說「與ActiveJob」。您發送的網址不是來自ActiveJob。回購所有人(@MikePerham)回覆說,你不能 –
謝謝。我已將'Sidekiq.default_worker_options = {retry:5}'添加到我的課程中。但似乎工作更糟糕(有一天重試很多次!)。默認的重試次數是25.那麼我不能自定義它嗎? – scho