Dedicating a DJ(Delayed job) worker to a specific queue in heroku.

1 minute read

Let's say you have a vey important procedure that takes a while, and you need to process it in background, but you still want to execute ASAP.

I'm using Delayed Job on Heroku, and could not find a lot of tutorials to do this simple task.

So here is the simplest way to achieve this ability, you can raise a process/deamon  that will have only one queue to work on. (Dealyed job worker by default is queue agnostic, just process all jobs)

In procfile:

urgentworker:  QUEUE=urgent bundle exec rake jobs:work

You can call the worker in any name you want and even define multiple workers for multiple queues.
And in the "urgent" job just define the queue name to be "urgent" the worker will process only jobs in this queue.

example:

handle_asynchronously :some_job, :queue => "urgent'

This will also work for Resque.

Notice that for rescue you can write QUEUE=* but for delayed job you can't.

Leave a Comment