Sha256: 7f10a37c83333f311535215a934f6ea2d17a3c1128e34a3ba3be534c34dd424a
Contents?: true
Size: 1.05 KB
Versions: 17
Compression:
Stored size: 1.05 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 "Channel-level exception handling" do |client| channel = AMQ::Client::Channel.new(client, 1) channel.open do puts "Channel #{channel.id} is now open" show_stopper = Proc.new { client.disconnect do puts puts "AMQP connection is now properly closed" EM.stop end } channel.on_error do puts "Oops, there is a channel-levle exceptions!" EM.add_timer(1.2) { show_stopper.call } end # amq.* names are reserevd so this causes a channel-level exception. MK. x = AMQ::Client::Exchange.new(client, channel, "amq.client.examples.extensions.x1", :direct) x.declare(false, false, false, true, false) EM.add_timer(1) do if channel.closed? puts "1 second later channel #{channel.id} is closed" end end Signal.trap "INT", show_stopper Signal.trap "TERM", show_stopper EM.add_timer(2, show_stopper) end end
Version data entries
17 entries across 17 versions & 1 rubygems