How to retry a specific queue of failed Resque jobs

Posted on 14 November 2011

Resque has a very handy interface for managing the queue of jobs but it falls short when jobs fail.

In order to only retry a specific queue drop onto the command line and run the following...

jobs = Resque::Failure.all(0, X)

Where X is the total number of failed messages.

jobs.each_with_index {|j,i| Resque::Failure.requeue(i) if j["queue"] == "queue_name" }

It's important you loop around all the jobs, filtering inside the loop, as the requeue method relies on the index being accurate so it retries the correct job.

Note that as each job is retried it wont clear the failed job out. You'll know if the job is successful, however, if your failed jobs list doesn't grow.

About Paul

Paul works for Kyan web design agency in Surrey, UK as a Ruby on Rails developer.

Follow Paul on Twitter

Email: paulsturgess [at] gmail.com

Read more articles in the archive →

Got something to say?