Provides Resque with three levels of (named) priority for a single queue.
require 'resque/plugins/priority' class Job extend Resque::Plugins::Priority @queue = :primary def self.perform(record) puts @queue #=> :primary_low puts @priority #=> :low other_stuff_and_junk end end # Enqueuing the job Resque.enqueue_with_priority(:low, Job, params)
The above code creates a new Job in the
:primary_low queue. There are three variations on the queues:
These three priorities produce queue names like, assuming
@queue is set to "queuename", like:
A Resque worker would then use a
QUEUE variable like:
self.perform methods have have two instance variables available to them:
@queue is nothing new, it's provided by Resque by default, but Priority has appended the current priority to the existing value; resulting in the actual queue the job originated from (e.g. ":queuename_high").
@priority provides you with the priority (e.g. ":high") of the current job execution.