class RabbitHutch::Consumer
Controls the consumers that are to be kicked off based on the config file
Public Class Methods
new(consumers)
click to toggle source
# File lib/consumer.rb, line 8 def initialize(consumers) @consumers = consumers end
Public Instance Methods
handle_message(metadata, payload)
click to toggle source
Raised on receipt of a message from RabbitMq and uses the appropriate appender
# File lib/consumer.rb, line 13 def handle_message(metadata, payload) # loop through appenders and fire each as required @consumers.each do |consumer| action = metadata.routing_key.split('.', 2).first if(action == "publish") exchange = metadata.attributes[:headers]["exchange_name"] queue = metadata.routing_key.split('.', 2).last item = {:date => Time.now, :exchange => exchange, :queue => queue, :routing_keys => metadata.attributes[:headers]["routing_keys"].inspect, :attributes => metadata.attributes.inspect, :payload => payload.inspect } consumer.log_event(item) end end end