Sparrow - Ruby 消息队列


MIT
跨平台
Ruby

软件简介

Sparrow 是一个非常快速而且轻量级的 Ruby 消息队列,遵循 memcached 协议,意味着你可以使用任何 Ruby 的 memcached
客户端来连接到 Sparrow 服务。Sparrow 将消息保存在内存中,并在关闭时通过 SQLite 将消息持久化到磁盘。

示例代码:

class MyQueue < MQueue::Queue
  def on_message(args)
    puts "Received msg with args: #{args.inspect}"
  end
end

SQS.access_key_id = 'YOURACCESSKEYID'
SQS.secret_access_key = 'YOURSECRETACCESSKEY'

servers = [
   MQueue::Protocols::Sparrow.new({:host => 'localhost', :port => 11212, :weight => 1}),
   MQueue::Protocols::SQS.new({:weight => 0})
]

MyQueue.servers = servers
MyQueue.publish 'test'
MyQueue.run

MyQueue.publish 'test'

MyQueue.run