Class: Euston::Daemons::Pipeline::EventProcessor::Component

Inherits:
Euston::DaemonComponent show all
Includes:
EventHandlerPrivateMethodNames
Defined in:
lib/euston-daemons/pipeline/lib/event_processor/component.rb

Instance Method Summary collapse

Methods inherited from Euston::DaemonComponent

#run, #stop

Methods included from Exceptions

#ignorable_exception?

Constructor Details

#initialize(channel, references, id = 1, logger = Euston::NullLogger.instance) ⇒ Component

Returns a new instance of Component.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/euston-daemons/pipeline/lib/event_processor/component.rb', line 8

def initialize channel, references, id = 1, logger = Euston::NullLogger.instance
  @channel = channel
  @channel.prefetch = 1
  @id = id
  @references = references
  @log = logger
  @process_method = method(:process_message)
  @stopwatch = Stopwatch.new.when(:finished => method(:log_elapsed_time))

  @subscriptions = @references.map do |r|
    { :reference => r,
      :subscription => RabbitMq::RetryingSubscription.new(@channel, r.queue_name, @log)
                                                     .when(:message_received => @process_method) }
  end
end