rabbitmq-tutorials/ruby/emit_log_topic.rb
Caique Hitoshi Mitsuoka d241706976 Update ruby tutorial five
2018-02-19 17:08:22 -03:00

16 lines
389 B
Ruby

#!/usr/bin/env ruby
require 'bunny'
connection = Bunny.new(automatically_recover: false)
connection.start
channel = connection.create_channel
exchange = channel.topic('topic_logs')
severity = ARGV.shift || 'anonymous.info'
message = ARGV.empty? ? 'Hello World!' : ARGV.join(' ')
exchange.publish(message, routing_key: severity)
puts " [x] Sent #{severity}:#{message}"
connection.close