/usr/share/doc/ruby-amqp/examples/legacy/callbacks.rb is in ruby-amqp 0.9.5-2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | #!/usr/bin/env ruby
# encoding: utf-8
require "bundler"
Bundler.setup
$:.unshift File.expand_path("../../lib", __FILE__)
require "amqp"
AMQP.start(:host => "localhost") do |connection|
# Send Connection.Close on Ctrl+C
trap(:INT) do
unless connection.closing?
connection.close { exit! }
end
end
@counter = 0
amq = AMQP::Channel.new
amq.prefetch(64, false) do
puts "basic.qos callback has fired"
end
amq.recover do
puts "basic.recover callback has fired"
end
10.times do
amq.queue("") do |queue|
puts "Queue #{queue.name} is now declared."
puts "All queues: #{amq.queues.map { |q| q.name }.join(', ')}"
@counter += 1
end
end
EM.add_timer(0.3) do
connection.disconnect do
puts "AMQP connection is now closed."
EM.stop
end
end
end
|