Ruby 消息隊列:Sparrow
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
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!