Sha256: f999680d30958dce90002e6de23e49a1a862febd7e35841b85738e30a933365a

Contents?: true

Size: 1.27 KB

Versions: 32

Compression:

Stored size: 1.27 KB

Contents

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

__dir = File.dirname(File.expand_path(__FILE__))
require File.join(__dir, "..", "example_helper")

amq_client_example "Handling a channel-level exception" do |connection|
  channel = AMQ::Client::Channel.new(connection, 1)
  channel.open do
    puts "Channel #{channel.id} is now open!"

    channel.on_error do |ch, close|
      puts "Handling a channel-level exception: #{close.reply_text}"
    end

    EventMachine.add_timer(0.4) do
      # these two definitions result in a race condition. For sake of this example,
      # however, it does not matter. Whatever definition succeeds first, 2nd one will
      # cause a channel-level exception (because attributes are not identical)
      AMQ::Client::Queue.new(connection, channel, "amqpgem.examples.channel_exception").declare(false, false, false, true) do |queue|
        puts "#{queue.name} is ready to go"
      end

      AMQ::Client::Queue.new(connection, channel, "amqpgem.examples.channel_exception").declare(false, true, false, false) do |queue|
        puts "#{queue.name} is ready to go"
      end
    end
  end


  show_stopper = Proc.new do
    $stdout.puts "Stopping..."
    connection.close { EventMachine.stop }
  end

  Signal.trap "INT", show_stopper
  EM.add_timer(2, show_stopper)
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
amq-client-1.0.4 examples/eventmachine_adapter/error_handling/handling_a_channel_level_exception.rb
amq-client-1.0.3 examples/eventmachine_adapter/error_handling/handling_a_channel_level_exception.rb
amq-client-1.1.0.pre1 examples/eventmachine_adapter/error_handling/handling_a_channel_level_exception.rb
amq-client-1.0.2 examples/eventmachine_adapter/error_handling/handling_a_channel_level_exception.rb
amq-client-1.0.1 examples/eventmachine_adapter/error_handling/handling_a_channel_level_exception.rb
amq-client-1.0.0 examples/eventmachine_adapter/error_handling/handling_a_channel_level_exception.rb
amq-client-0.9.12 examples/eventmachine_adapter/error_handling/handling_a_channel_level_exception.rb
amq-client-0.9.11 examples/eventmachine_adapter/error_handling/handling_a_channel_level_exception.rb
amq-client-0.9.10 examples/eventmachine_adapter/error_handling/handling_a_channel_level_exception.rb
amq-client-0.9.9 examples/eventmachine_adapter/error_handling/handling_a_channel_level_exception.rb
amq-client-0.9.8 examples/eventmachine_adapter/error_handling/handling_a_channel_level_exception.rb
amq-client-0.9.7 examples/eventmachine_adapter/error_handling/handling_a_channel_level_exception.rb
amq-client-0.9.6 examples/eventmachine_adapter/error_handling/handling_a_channel_level_exception.rb
amq-client-0.9.5 examples/eventmachine_adapter/error_handling/handling_a_channel_level_exception.rb
amq-client-0.9.4 examples/eventmachine_adapter/error_handling/handling_a_channel_level_exception.rb
amq-client-1.0.0.pre2 examples/eventmachine_adapter/error_handling/handling_a_channel_level_exception.rb
amq-client-0.9.3 examples/eventmachine_adapter/error_handling/handling_a_channel_level_exception.rb
amq-client-1.0.0.pre1 examples/eventmachine_adapter/error_handling/handling_a_channel_level_exception.rb
amq-client-0.9.2 examples/eventmachine_adapter/error_handling/handling_a_channel_level_exception.rb
amq-client-0.9.1 examples/eventmachine_adapter/error_handling/handling_a_channel_level_exception.rb