BunnyRabbitMQ 的 Ruby 开发包
Bunny 是 RabbitMQ 的客户端开发包,专注于易用性。它功能齐全,支持所有最近的 RabbitMQ 功能,并且没有任何重量级的依赖关系。
示例代码:
require "bunny"
# Start a communication session with RabbitMQ
conn = Bunny.new
conn.start
# open a channel
ch = conn.create_channel
# declare a queue
q  = ch.queue("test1")
# publish a message to the default exchange which then gets routed to this queue
q.publish("Hello, everybody!")
# fetch a message from the queue
delivery_info, metadata, payload = q.pop
puts "This is the message: #{payload}"
# close the connection
conn.stop评论
