Sha256: 898dc334393e2c24ad591d3710c202aa0568bb29e8b521730c0d07ddca850851

Contents?: true

Size: 1.42 KB

Versions: 17

Compression:

Stored size: 1.42 KB

Contents

JobQueue
========

`job_queue` allows you to use lots of message queues with exactly the same interface so you don't need to worry about which queue to pick :)

This should get you started:

    require 'rubygems'
    require 'job_queue'

Before you can do anything you must specify an adapter to use

    JobQueue.adapter = JobQueue::BeanstalkAdapter.new

Jobs can then be simply added to the queue

    JobQueue.put("flubble bubble")
    
In your workers you'll want to subscribe to a queue

    JobQueue.subscribe do |job|
      puts job
    end

This subscribe block takes care of waiting for the next job to arrive and the block is passed exactly what you passed in. If you want to exit the loop just throw :stop.

    JobQueue.subscribe do |job|
      # Wait - I changed my mind!
      throw :stop
    end

What should you put on the queue
--------------------------------

You might love Ruby right now, but why lock yourself in? Often the kinds of things you use queues for are the kind of things you'll want to optimize. This is a good place to start:

    JSON.generate({:some => "hash"})
    JSON.parse(job)

Can you show me a nice processing daemon?
-----------------------------------------

Yes. Just a minute...

Adapters
========

Take your pick! Right now we have:

Beanstalk
---------
<http://xph.us/software/beanstalkd/>

AMQP
----
<http://github.com/tmm1/amqp/>

You need to run all your code within an eventmachine loop to use AMQP.

Version data entries

17 entries across 17 versions & 3 rubygems

Version Path
mloughran-job_queue-0.0.10 README.markdown
mloughran-job_queue-0.0.11 README.markdown
mloughran-job_queue-0.0.3 README.markdown
mloughran-job_queue-0.0.4 README.markdown
mloughran-job_queue-0.0.5 README.markdown
mloughran-job_queue-0.0.6 README.markdown
mloughran-job_queue-0.0.7 README.markdown
mloughran-job_queue-0.0.8 README.markdown
mloughran-job_queue-0.0.9 README.markdown
newbamboo-job_queue-0.0.5 README.markdown
newbamboo-job_queue-0.0.6 README.markdown
newbamboo-job_queue-0.0.7 README.markdown
newbamboo-job_queue-0.0.8 README.markdown
job_queue-0.0.12 README.markdown
job_queue-0.0.11 README.markdown
job_queue-0.0.10 README.markdown
job_queue-0.0.9 README.markdown