云消息系统:nats
jopen
11年前
nats 是一个轻量级的云消息系统,使用 Ruby 开发。支持:
- MRI 1.8 and 1.9 (Performance is best on 1.9.3)
- Rubinius
- JRuby
基本用法:
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
项目主页:http://www.open-open.com/lib/view/home/1382151689546