rabbitmq-tutorials/ruby/emit_log.rb
Jakub Stastny aka botanicus d83ca8fadc Ruby: new_task.rb, ARGV fix.
2011-05-03 04:14:32 +02:00

20 lines
396 B
Ruby
Executable File

#!/usr/bin/env ruby
# encoding: utf-8
require "amqp"
AMQP.start(:host => "localhost") do |connection|
channel = AMQP::Channel.new(connection)
exchange = channel.fanout("logs")
message = ARGV.empty? ? "info: Hello World!" : ARGV.join(" ")
exchange.publish(message)
puts " [x] Sent #{message}"
EM.add_timer(0.5) do
connection.close do
EM.stop { exit }
end
end
end