rabbitmq-tutorials/ruby/receive_logs.rb
2018-02-19 17:08:22 -03:00

24 lines
434 B
Ruby

#!/usr/bin/env ruby
require 'bunny'
connection = Bunny.new
connection.start
channel = connection.create_channel
exchange = channel.fanout('logs')
queue = channel.queue('', exclusive: true)
queue.bind(exchange)
puts ' [*] Waiting for logs. To exit press CTRL+C'
begin
queue.subscribe(block: true) do |_delivery_info, _properties, body|
puts " [x] #{body}"
end
rescue Interrupt => _
channel.close
connection.close
end