/usr/share/doc/ruby-bunny/examples/simple_ack_08.rb is in ruby-bunny 0.7.8-1.
This file is owned by root:root, with mode 0o644.
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 | # encoding: utf-8
# simple_ack_08.rb
# Assumes that target message broker/server has a user called 'guest' with a password 'guest'
# and that it is running on 'localhost'.
# If this is not the case, please change the 'Bunny.new' call below to include
# the relevant arguments e.g. b = Bunny.new(:user => 'john', :pass => 'doe', :host => 'foobar')
$:.unshift File.dirname(__FILE__) + '/../lib'
require 'bunny'
b = Bunny.new(:logging => true)
# start a communication session with the amqp server
b.start
# declare a queue
q = b.queue('test1')
# publish a message to the queue
q.publish('Testing acknowledgements')
# get message from the queue
msg = q.pop(:ack => true)[:payload]
# acknowledge receipt of message
q.ack
puts 'This is the message: ' + msg + "\n\n"
# close the client connection
b.stop
|