Bunny 是一个非常受欢迎的、易用的、可维护的 RabbitMQ 2.0+ 的 Ruby 客户端开发包。
示例代码:
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