Project

remq-rb

0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
Redis Message Queue (ReMQ) is a message queue backed by the awesome key-value store, Redis.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 0.9
~> 0.8

Runtime

~> 1.7
~> 3.0
 Project Readme

ReMQ.rb

Build Status

Redis Message Queue (ReMQ) is a message queue built on top of the awesome Redis key-value store.

This is the Ruby clone of the original ReMQ PHP library.

Getting ReMQ

ReMQ.rb is packaged as a gem, so assuming you have RubyGems installed you simply run gem install remq-rb or add it to your Gemfile.

Once it's installed just add require "ReMQ" to your script.

Jobs

Jobs are stored as classes. The class must have a perform method which can take a variable number of parameters/

class Job

  def self.perform(param1, param2)
    puts "Ran job with #{param1} and #{param2}"
  end

end

Queuing Jobs

Instead of creating a queue for each job, ReMQ allows multiple jobs per queue. This is for simplicity's sake, and there is no other reason behind it.

queue = ReMQ::Queue.new('name')
queue.enqueue(Job, 'param1', 'param2')

Processing Jobs

To process a job, you need to create a worker for the queue.

worker = ReMQ::Worker.new('name')

You can also add additional queues to the process.

worker.add_queue('other')

You can also match queue names.

worker.add_queue('*')
worker.add_queue('namespaced:*')

Running the worker.

worker.run(:time => 60)
worker.run(:count => 10)
worker.run()