Home > resque-dynamic-queues

resque-dynamic-queues

Resque-dynamic-queues is a project mainly written in Ruby, based on the MIT license.

A plugin for Resque that supports dynamic priority scheduling

Depends on Resque 1.10 (However, requires redis-namespace 1.10)

Resque Dynamic Queues

This plugin does two things. It implements the concept of dynamic queues and it selects the currently slowest queue. Dynamic queues are queues that are automatically removed when they're empty, allowing queues to mirror transient objects in the app.

The plugin records work performed and elapsed time for each queue, and always selects the queue with the lowest current performance to process next. Since all the queues are active (they have jobs), the first selected queue will be usable.

Usage

After require 'resque':

require 'resque/plugins/dynamic_queues'

Then, for dynamic queues, once all jobs have been queued: Resque::Plugins::DynamicQueues::Base.activate('group1', 'queue3')

This adds the queue to a queue group.

To randomly process jobs from all queues in the queue group: worker = Resque::Plugins::DynamicQueues::Worker.new('@group1') worker.work

Note the "@" prefix. This indicates that group1 is a queue group and not a queue.

Written by Joshua Harvey