简体   繁体   中英

Retry sidekiq job if it is in dead queue in rails

I want to write a cron job which fetches the sidekiq job from the dead queue and retry it, as we can do it from sidekiq's Web UI, I want to do the same through the code.

The dead queue is accessed withSidekiq::DeadSet which has a retry_all method .

Sidekiq::DeadSet.new.retry_all

This is a thin wrapper around iterating over each job in the queue and calling retry . SideKiq::DeadSet is Enumerable so you can use methods like select and each . The wiki page has a good example .

ds = Sidekiq::DeadSet.new

# Retry only jobs of FixedWorker class whose first argument is 123.
ds.select { |job|
  job.klass == 'FixedWorker' && job.args[0] == 123
}.map(&:retry)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM