rabbitmq-tutorials/ruby/receive.rb
Michael Klishin e9d2c78e0a Cosmetics
2013-07-17 21:54:25 +04:00

21 lines
383 B
Ruby

#!/usr/bin/env ruby
# encoding: utf-8
require "bunny"
conn = Bunny.new
conn.start
ch = conn.create_channel
q = ch.queue("hello")
puts " [*] Waiting for messages in #{q.name}. To exit press CTRL+C"
q.subscribe(:block => true) do |delivery_info, properties, body|
puts " [x] Received #{body}"
# cancel the consumer to exit
delivery_info.consumer.cancel
end
conn.close