Sha256: 309569ff0f82cf38312058ac0ba8df5f83f5fc4ae7a72c00afd54a8963b8d063

Contents?: true

Size: 722 Bytes

Versions: 8

Compression:

Stored size: 722 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|
  puts "Connected"
  AMQP::Channel.new(connection) do |channel, open_ok|
    puts "Opened a channel"
    channel.on_error do |arg|
      raise "Channel-level exception: #{arg.inspect}"
    end
    exchange = channel.fanout("amq.fanout")

    channel.queue("", :auto_delete => true, :exclusive => true) do |queue, declare_ok|
      queue.purge do |_|
        puts "Purged #{queue.name}"
      end

      EventMachine.add_timer(0.5) do
        connection.close {
          EM.stop { exit }
        }
      end # EventMachine.add_timer
    end # channel.queue
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

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