Sha256: 1d9a762c916bf9640e6fe471917a79ac7767dbf150e5736d2f6a17fb0dfe8954

Contents?: true

Size: 708 Bytes

Versions: 8

Compression:

Stored size: 708 Bytes

Contents

#!/usr/bin/env ruby
# encoding: utf-8

require "rubygems"
require "amqp"

AMQP.start("amqp://guest:guest@dev.rabbitmq.com:5672/") do |connection, open_ok|
  AMQP::Channel.new do |channel, open_ok|
    exchange = channel.fanout("amq.fanout")

    channel.queue("", :auto_delete => true, :exclusive => true) do |queue, declare_ok|
      queue.bind(exchange) do |_|
        puts "Bound. Publishing a message..."
        exchange.publish("Ohai!")
      end

      EventMachine.add_timer(0.5) do
        queue.pop do |response|
          puts "Fetched a message: #{response.inspect}. Shutting down..."

          connection.close {
            EM.stop { exit }
          }
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
amqp-0.8.0.rc11 examples/guides/queues/08_poll_for_messages.rb
amqp-0.8.0.rc10 examples/guides/queues/08_poll_for_messages.rb
amqp-0.8.0.rc9 examples/guides/queues/08_poll_for_messages.rb
amqp-0.8.0.rc8 examples/guides/queues/08_poll_for_messages.rb
amqp-0.8.0.rc7 examples/guides/queues/08_poll_for_messages.rb
amqp-0.8.0.rc6 examples/guides/queues/08_poll_for_messages.rb
amqp-0.8.0.rc5 examples/guides/queues/08_poll_for_messages.rb
amqp-0.8.0.rc4 examples/guides/queues/08_poll_for_messages.rb