main
1#!/env ruby
2# encoding: utf-8
3
4require "bunny"
5
6connection = Bunny.new
7connection.start
8
9channel = connection.create_channel
10queue = channel.queue("hello")
11
12puts " [*] Waiting for messages in #{queue.name}. To exit press CTRL+C"
13queue.subscribe(block: true) do | delivery_info, properties, body|
14 puts " [x] Received #{body}"
15 # cancel the consumer to exit
16 delivery_info.consumer.cancel
17end
18