Today I found about 100k Resque jobs in the failed queue. Due to a small error in some user content, those jobs all failed. After fixing the problem, how do you reprocess all those jobs?
Option one: go to the resque-web
backend and click retry about 100.000 times.
Option two: do some cool ruby commands.
~
Resque offers you direct access to the failed queue and also provides a method to requeue
jobs. How easy can it be, right?
With Resque::Failure.all(0,1)
you retrieve the first job from the failed queue. Resque::Failure.all
is simply a ruby Array.
To requeue jobs, you can use Resque::Failure.requeue(index)
where index corresponds to the index of the job in the Resque::Failure.all
Array.
To requeue all jobs in the failed queue, you can simply run the following commands:
# Requeue all jobs in the failed queue
(Resque::Failure.count-1).downto(0).each { |i| Resque::Failure.requeue(i) }
# Clear the failed queue
Resque::Failure.clear
That’s all there is to it, really. Happy processing!