22 lines
518 B
Ruby
22 lines
518 B
Ruby
#!/usr/bin/env ruby
|
|
require 'bunny'
|
|
|
|
connection = Bunny.new(automatically_recover: false)
|
|
connection.start
|
|
|
|
channel = connection.create_channel
|
|
queue = channel.queue('hello')
|
|
|
|
begin
|
|
puts ' [*] Waiting for messages. To exit press CTRL+C'
|
|
# block: true is only used to keep the main thread
|
|
# alive. Please avoid using it in real world applications.
|
|
queue.subscribe(block: true) do |_delivery_info, _properties, body|
|
|
puts " [x] Received #{body}"
|
|
end
|
|
rescue Interrupt => _
|
|
connection.close
|
|
|
|
exit(0)
|
|
end
|