Knowledge Base/Community Forums/Custom Components

Five Useful Resque Gems

Tyler Bird
posted this on May 02, 2012 04:29 PM

So you’ve decided to use Resque on Engine Yard Cloud as your background queue, probably because Redis is already running on your instances and you’re already using ruby and JSON daily for your app.  Good choice!

But did you know that there are many useful ancillary gems that can make your resque system even better?  Here we’ll highlight five useful resque gems that give you some extra features and insight into your queue.  And then at the end there’s a link to even more gems where you can find more features about running a queue with resque.

1) By default, a job gets sent to resque it would be performed at that moment.  But with the resque-scheduler gem you can add the ability for the action of delaying the execution of a job and also scheduling exactly when a job will run.

2) Now let’s say that your job that was delayed dies or can’t run.  Then let’s add resque-retry into the mix because it can give you retry counts with limits based on specific exceptions.  It even adds information to your resque-web in a new tab.

3) Now that you can schedule jobs let’s add the ability to send email with resque.  Let’s get that email newsletter sent out first thing 7:30 EST with ActionMailer and the resque_mailer gem.  After you add this to your mailer just create a separate queue called mailer.  See the README on github for more info.

4) One of the best features of resque is the ability to look at the queue with the sinatra based view called resque-web.  Sometimes though you’ll get jobs that fail and stick in the queue and there’s no way to clear them out.  Until you add the resque-cleaner gem.  Not only does this add many powerful new resque-web UI features to manage your failed jobs, but it also adds rails console methods as well.

5) Some jobs just take a long time to complete.  Wouldn’t it be nice to have a completion bar?  Even implement a status strategy for your workers?  Well resque-status gives you the tools to do that.

This is just enough to spark your imagination.  There are even more plugins available at the resque wiki on github.  I suggest you go there and explore the list and read through the readme’s to find the hidden treasures that await.  Please feel free to share your thoughts and experiences with comments below!