云消息系統:nats
nats 是一個輕量級的云消息系統,使用 Ruby 開發。支持:
- MRI 1.8 and 1.9 (Performance is best on 1.9.3)
- Rubinius
- JRuby </ul>
基本用法:
require "nats/client"NATS.start do
Simple Subscriber
NATS.subscribe('foo') { |msg| puts "Msg received : '#{msg}'" }
Simple Publisher
NATS.publish('foo.bar.baz', 'Hello World!')
Unsubscribing
sid = NATS.subscribe('bar') { |msg| puts "Msg received : '#{msg}'" } NATS.unsubscribe(sid)
Requests
NATS.request('help') { |response| puts "Got a response: '#{response}'" }
Replies
NATS.subscribe('help') { |msg, reply| NATS.publish(reply, "I'll help!") }
Stop using NATS.stop, exits EM loop if NATS.start started the loop
NATS.stop
end</pre>
項目主頁:http://www.baiduhome.net/lib/view/home/1382151689546
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!