From: Brian Candler Date: 2009-12-24T05:42:05+09:00 Subject: Re: Suggestions for a distributed job queue A couple of other options: (1) AMQP, e.g. rabbitmq. I believe it comes with ruby bindings. Can be made as fault-tolerant as you like :-) (2) Depending on your needs, you could consider rolling your own with DRb. This means at least you know the system inside-out and can easily customise it - although avoiding the queue server itself being a SPOF is awkward. Here are a couple of working proofs-of-concept. In-RAM queue ============ ---- server ---- require 'drb' require 'thread' q = Queue.new # or SizedQueue.new(1000) DRb.start_service("druby://127.0.0.1:9911", q) DRb.thread.join ---- client ---- require 'drb' DRb.start_service q = DRbObject.new(nil, "druby://localhost:9911") q.push "abc" puts q.pop On-disk queue using Madeleine ============================= ---- server ---- require 'rubygems' require 'madeleine' class MadQueue def initialize(madeleine) @madeleine = madeleine end # Read operations don't need to go via command objects (if you don't # care about synchronization) def length @madeleine.system.length end class Pusher def initialize(data) @data = data end def execute(system) system.push(@data) end end class Popper def execute(system) system.shift end end def push(data) @madeleine.execute_command(Pusher.new(data)) end def pop @madeleine.execute_command(Popper.new) end end require 'drb' madeleine = SnapshotMadeleine.new("madqueue.dir") { [] } Thread.new(madeleine) { puts "Taking snapshot every 30 seconds." while true sleep(30) madeleine.take_snapshot end } DRb.start_service("druby://127.0.0.1:9911", MadQueue.new(madeleine)) DRb.thread.join ---- client ---- Same as above -- Posted via http://www.ruby-forum.com/.