Class: StompServer::QueueMonitor
- Inherits:
-
Object
- Object
- StompServer::QueueMonitor
- Defined in:
- lib/stomp_server/queue_manager.rb
Instance Method Summary collapse
-
#initialize(qstore, queues) ⇒ QueueMonitor
constructor
A new instance of QueueMonitor.
- #monitor(count) ⇒ Object
- #start ⇒ Object
Constructor Details
#initialize(qstore, queues) ⇒ QueueMonitor
Returns a new instance of QueueMonitor.
23 24 25 26 27 28 |
# File 'lib/stomp_server/queue_manager.rb', line 23 def initialize(qstore,queues) @qstore = qstore @queues = queues @stompid = StompServer::StompId.new puts "QueueManager initialized" end |
Instance Method Details
#monitor(count) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/stomp_server/queue_manager.rb', line 35 def monitor(count) return unless @qstore.methods.include?('monitor') users = @queues['/queue/monitor'] return if users.size == 0 stats = @qstore.monitor return if stats.size == 0 body = '' stats.each do |queue,qstats| body << "Queue: #{queue}\n" qstats.each {|stat,value| body << "#{stat}: #{value}\n"} body << "\n" end headers = { 'message-id' => @stompid[count], 'destination' => '/queue/monitor', 'content-length' => body.size.to_s } frame = StompServer::StompFrame.new('MESSAGE', headers, body) users.each {|user| user.user.stomp_send_data(frame)} end |
#start ⇒ Object
30 31 32 33 |
# File 'lib/stomp_server/queue_manager.rb', line 30 def start count =0 EventMachine::add_periodic_timer 5, proc {count+=1; monitor(count) } end |