class MessageQueue::ConsumableRunner

Attributes

consumables[R]

Public Class Methods

new(consumables) click to toggle source
# File lib/message_queue/consumable_runner.rb, line 7
def initialize(consumables)
  @consumables = consumables
end

Public Instance Methods

run(options = {}) click to toggle source
# File lib/message_queue/consumable_runner.rb, line 11
def run(options = {})
  begin
    block = !!options[:block]
    consumables.each_with_index do |consumable, index|
      # Blocks the last consumer
      opts = if index < consumables.size - 1
               {}
             else
               { :block => block }
             end
      consumable.new.subscribe(opts)
    end
  rescue SignalException => ex
    logger.info "Received Signal #{ex}"
  end
end