21 lines
359 B
Ruby
21 lines
359 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 "Will wait from messages in #{q.name}"
|
|
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
|