examples/hello_world.rb in amqp-0.8.0.rc2 vs examples/hello_world.rb in amqp-0.8.0.rc3

- old
+ new

@@ -7,23 +7,22 @@ $:.unshift(File.expand_path("../../lib", __FILE__)) require 'amqp' EventMachine.run do - AMQP.connect(:host => 'localhost') do |connection| - puts "Connected to AMQP broker" + connection = AMQP.connect(:host => '127.0.0.1') + puts "Connected to AMQP broker. Running #{AMQP::VERSION} version of the gem..." - channel = AMQP::Channel.new(connection) - queue = channel.queue("amqpgem.examples.hello_world") - exchange = channel.default_exchange + channel = AMQP::Channel.new(connection) + queue = channel.queue("amqpgem.examples.hello_world", :auto_delete => true) + exchange = channel.direct("") - queue.subscribe do |payload| - puts "Received a message: #{payload}. Disconnecting..." + queue.subscribe do |payload| + puts "Received a message: #{payload}. Disconnecting..." - connection.close { - EM.stop { exit } - } - end + connection.close { + EM.stop { exit } + } + end - exchange.publish "Hello, world!", :routing_key => queue.name - end + exchange.publish "Hello, world!", :routing_key => queue.name end