Class: ReliableMsg::RetentionHistory

Inherits:
Object
  • Object
show all
Includes:
DRbUndumped
Defined in:
lib/ap4r/retention_history.rb

Overview

This class is too much experimental. The aim: for performance monitoring, records unprocessed message count in every queues at some interval.

Constant Summary collapse

LOOP_INTERVAL =

to_i method is required for ActiveSupport 2.0 where return value of seconds method is not Fixnum.

1.seconds.to_i
SHELF_LIFE =
10.minutes.to_i

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(qm, logger, config) ⇒ RetentionHistory

Returns a new instance of RetentionHistory.



22
23
24
25
26
27
28
# File 'lib/ap4r/retention_history.rb', line 22

def initialize(qm, logger, config)
  @data = {}
  @qm = qm
  @logger = logger
  @config = config
  @qm.add_lifecycle_listener(self, 'retention')
end

Instance Attribute Details

#dataObject (readonly)

SHELF_LIFE = 10.seconds.to_i



20
21
22
# File 'lib/ap4r/retention_history.rb', line 20

def data
  @data
end

Instance Method Details

#startObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/ap4r/retention_history.rb', line 30

def start
  @collector = Thread.start do
    loop do
      begin
        sleep LOOP_INTERVAL
        collect
        sweep
      rescue Exception => ex
        @logger.warn("message retention history (collect) #{ex.inspect}")
        @logger.warn(ex.backtrace.join("\n\t"))
      end
    end
  end
end

#stopObject



45
46
47
# File 'lib/ap4r/retention_history.rb', line 45

def stop
  @collector.terminate
end