randombits
randombits

Reputation: 48450

Sidekiq: change rate of retry for failed job?

I have jobs of a particular type that I'd like to have retry more frequently than set by the default Sidekiq interval. Is this currently possible? Ideally the job would retry every 5 seconds for up to a minute. Not entirely sure this is currently something that's trivial to plugin to a Sidekiq job.

Upvotes: 22

Views: 18465

Answers (3)

antonpot
antonpot

Reputation: 51

I'm answering if calling 10.minutes in the block works, because I can't comment on an answer.

According to the Sidekiq code, you need to pass an Integer, or either :kill or :discard symbols.

10.minutes returns an instance of ActiveSupport::Duration

This means that the following would work:

class Worker
  include Sidekiq::Worker

  sidekiq_retry_in { 10.minutes.to_i }
end

Source

Upvotes: 2

CHBLU
CHBLU

Reputation: 21

If you need other range, can use minute syntax

sidekiq_retry_in do |_count|
  10.minutes
end

Upvotes: 1

Bart
Bart

Reputation: 2656

According to: https://github.com/mperham/sidekiq/wiki/Error-Handling you can do this:

class Worker
  include Sidekiq::Worker

  sidekiq_retry_in do |count|
    5
  end
end

Upvotes: 34

Related Questions