Sparrow是一个非常快速而且轻量级的Ruby消息队列,遵循memcached协议,意味着你可以使用任何Ruby的memcached客户端来连接到Sparrow服务。Sparrow将消息保存在内存中,并在关闭时通过SQLite将消息持久化到磁盘。
示例代码:
classMyQueue<MQueue::Queuedefon_message(args)puts"Receivedmsgwithargs:#{args.inspect}"endendSQS.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=serversMyQueue.publish'test'MyQueue.runMyQueue.publish'test'MyQueue.run
评论