BunnyRabbitMQ 的 Ruby 开发包

联合创作 · 2023-10-01 03:28

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
浏览 4
点赞
评论
收藏
分享

手机扫一扫分享

编辑
举报
评论
图片
表情
推荐
点赞
评论
收藏
分享

手机扫一扫分享

编辑
举报