Skip to content

Instantly share code, notes, and snippets.

@vsavkin
Created February 13, 2012 00:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vsavkin/1812186 to your computer and use it in GitHub Desktop.
Save vsavkin/1812186 to your computer and use it in GitHub Desktop.
Example 2 for "Messaging for Rubyists"
require 'bunny'
# connecting to a broker
b = Bunny.new({}, {:spec => "09"})
b.start
# setup
e = b.exchange("exchange-02", :durable => true)
q = b.queue("queue-02")
q.bind e
# producer
e.publish("Message Body", :persistent => true)
# consumer
msg = q.pop
puts "This is the message: #{msg}"
puts "This is the payload: #{msg[:payload]}"
b.stop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment