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
|
# File 'lib/bunnish/command/count.rb', line 3
def self.run(argv, input_stream=$stdin, output_stream=$stdout)
params = Bunnish.parse_opts(argv)
host = params[:host]
port = params[:port]
user = params[:user]
password = params[:password]
durable = params[:durable]
queue_name = argv.shift
if queue_name.nil?
Bunnish.logger.error("queue-name is not set")
return 1
end
bunny = Bunny.new(:logging => false, :spec => '09', :host=>host, :port=>port, :user=>user, :pass=>password)
bunny.start
queue = bunny.queue(queue_name, :durable=>durable)
output_stream.puts queue.status[:message_count]
bunny.stop
end
|