Class: RosettaQueue::EventedManager

Inherits:
BaseManager show all
Defined in:
lib/rosetta_queue/consumer_managers/evented.rb

Instance Attribute Summary

Attributes inherited from BaseManager

#consumers

Instance Method Summary collapse

Methods inherited from BaseManager

#add, create, #initialize

Constructor Details

This class inherits a constructor from RosettaQueue::BaseManager

Instance Method Details

#startObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/rosetta_queue/consumer_managers/evented.rb', line 9

def start
  EM.run {
    trap_interruptions

    begin
      @consumers.each do |key, consumer|
        RosettaQueue.logger.info("Running consumer #{key} in event machine...")
        consumer.receive
      end
    rescue Exception => e
      RosettaQueue.logger.error("Exception thrown: #{$!}\n" + e.backtrace.join("\n\t"))
    end
  }
end

#stopObject



24
25
26
27
# File 'lib/rosetta_queue/consumer_managers/evented.rb', line 24

def stop
  RosettaQueue.logger.info("Shutting down event machine...")
  EM.stop
end