Skip to main content

Resque: how to requeue failed jobs

·159 words·1 min· ·
Ruby Resque
Ariejan de Vroom
Author
Ariejan de Vroom
Jack of all Trades, Professional Software Craftsman

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!

Related

Firefly 0.4.3 and Firefly Client 0.4.0 released
·109 words·1 min
Ruby Gems Urls Firefly Shortener
Upgrading to Mongoid Beta 6
·197 words·1 min
Ruby Rails Mongoid Monogdb
Bundler + Passenger with Rails 2.3.5? Yes, please!
·236 words·2 mins
Ruby Rails Bundler Passenger