rabbitmq-tutorials/ruby/send.rb
2011-05-03 05:00:38 +02:00

19 lines
382 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("hello")
AMQP::Exchange.default.publish("Hello World!", :routing_key => queue.name)
puts " [x] Sent 'Hello World!'"
EM.add_timer(0.5) do
connection.close do
EM.stop { exit }
end
end
end