Sha256: e254e61edc6c2ea3436e4cff2ed023d4d6a3c74cbd07465fa97250f72dd4df77

Contents?: true

Size: 1.2 KB

Versions: 27

Compression:

Stored size: 1.2 KB

Contents

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

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


EM.run do
  AMQ::Client::EventMachineClient.connect(:port     => 5672,
                                          :vhost    => "/amq_client_testbed",
                                          :user     => "amq_client_gem",
                                          :password => "amq_client_gem_password",
                                          :timeout        => 0.3,
                                          :on_tcp_connection_failure => Proc.new { |settings| puts "Failed to connect, this was NOT expected"; EM.stop }) do |client|

    client.on_tcp_connection_loss do |cl, settings|
      puts "tcp_connection_loss handler kicks in"
      cl.reconnect(false, 2)
    end

    show_stopper = Proc.new {
      client.disconnect {
        puts "Disconnected. Exiting…"
        EM.stop
      }
    }

    Signal.trap "INT",  show_stopper
    Signal.trap "TERM", show_stopper

    EM.add_timer(30, show_stopper)


    puts "Connected, authenticated. To really exercise this example, shut AMQP broker down for a few seconds. If you don't it will exit gracefully in 30 seconds."
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
amq-client-0.7.0.alpha35 examples/eventmachine_adapter/connection_loss_handler.rb
amq-client-0.7.0.alpha34 examples/eventmachine_adapter/connection_loss_handler.rb
amq-client-0.7.0.alpha33 examples/eventmachine_adapter/connection_loss_handler.rb
amq-client-0.7.0.alpha32 examples/eventmachine_adapter/connection_loss_handler.rb
amq-client-0.7.0.alpha31 examples/eventmachine_adapter/connection_loss_handler.rb
amq-client-0.7.0.alpha30 examples/eventmachine_adapter/connection_loss_handler.rb
amq-client-0.7.0.alpha29 examples/eventmachine_adapter/connection_loss_handler.rb
amq-client-0.7.0.alpha28 examples/eventmachine_adapter/connection_loss_handler.rb
amq-client-0.7.0.alpha27 examples/eventmachine_adapter/connection_loss_handler.rb
amq-client-0.7.0.alpha26 examples/eventmachine_adapter/connection_loss_handler.rb
amq-client-0.7.0.alpha25 examples/eventmachine_adapter/connection_loss_handler.rb
amq-client-0.7.0.alpha24 examples/eventmachine_adapter/connection_loss_handler.rb
amq-client-0.7.0.alpha23 examples/eventmachine_adapter/connection_loss_handler.rb
amq-client-0.7.0.alpha22 examples/eventmachine_adapter/connection_loss_handler.rb
amq-client-0.7.0.alpha21 examples/eventmachine_adapter/connection_loss_handler.rb
amq-client-0.7.0.alpha20 examples/eventmachine_adapter/connection_loss_handler.rb
amq-client-0.7.0.alpha19 examples/eventmachine_adapter/connection_loss_handler.rb
amq-client-0.7.0.alpha18 examples/eventmachine_adapter/connection_loss_handler.rb
amq-client-0.7.0.alpha17 examples/eventmachine_adapter/connection_loss_handler.rb
amq-client-0.7.0.alpha16 examples/eventmachine_adapter/connection_loss_handler.rb