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

20 lines
473 B
Ruby
Executable File

#!/usr/bin/env ruby
# encoding: utf-8
require "amqp"
AMQP.start(:host => "localhost") do |connection|
channel = AMQP::Channel.new(connection)
queue = channel.queue("task_queue", :durable => true)
message = ARGV.empty? ? "Hello World!" : ARGV.join(" ")
AMQP::Exchange.default.publish(message, :routing_key => queue.name, :persistent => true)
puts " [x] Sent #{message}"
EM.add_timer(0.5) do
connection.close do
EM.stop { exit }
end
end
end