rabbitmq-tutorials/ruby/receive.rb
Jakub Stastny aka botanicus 4f55a4fcbf Ruby: receive.rb
2011-05-03 04:30:15 +02:00

22 lines
397 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")
Signal.trap("INT") do
connection.close do
EM.stop { exit }
end
end
puts " [*] Waiting for messages. To exit press CTRL+C"
queue.subscribe do |body|
puts " [x] Received #{body}"
end
end