Class: Euston::Daemons::Pipeline::CommandLogger::Component

Inherits:
Euston::DaemonComponent show all
Extended by:
RabbitMq::Exchanges, RabbitMq::Queues
Defined in:
lib/euston-daemons/pipeline/lib/command_logger/component.rb

Instance Method Summary collapse

Methods inherited from Euston::DaemonComponent

#run, #stop

Methods included from Exceptions

#ignorable_exception?

Constructor Details

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

Returns a new instance of Component.



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

def initialize channel, id = 1, logger = Euston::NullLogger.instance
  @id = id
  @log = logger
  @channel = channel
  @channel.prefetch = 1
  @command_log = Log.new DaemonEnvironment.event_store_mongodb
  @exchange = self.class.get_exchange channel, :commands
  @queue = self.class.get_queue channel, @command_log.name
  @queue.bind @exchange, :routing_key => "#{@exchange.name}.#"

  @queue.when(:message_decode_failed => method(:log_failure),
              :message_failed        => method(:message_failed),
              :message_received      => method(:write_message_to_log))

  @consumer = @queue.consumer
end