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.
Asked
Active
Viewed 1,913 times
1 Answers
2
The dead queue is accessed with Sidekiq::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)

Schwern
- 153,029
- 25
- 195
- 336
-
But I don't want to retry all instead I want to check its parameter first and then retry for each job , so individually if want retry then how can I do?? – Puja Garg May 14 '20 at 08:17
-
1Please read the API wiki page. https://github.com/mperham/sidekiq/wiki/API#dead – Mike Perham May 14 '20 at 18:27
-
@PujaGarg `Sidekiq::DeadSet` is an enumerable. You can use normal enumerable functions like `select` and `each`. – Schwern May 15 '20 at 04:26