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 =
1.seconds
SHELF_LIFE =
10.minutes

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(qm, logger, config) ⇒ RetentionHistory

Returns a new instance of RetentionHistory.



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

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



18
19
20
# File 'lib/ap4r/retention_history.rb', line 18

def data
  @data
end

Instance Method Details

#startObject



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

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



43
44
45
# File 'lib/ap4r/retention_history.rb', line 43

def stop
  @collector.terminate
end