Sha256: ced27c26a1afeed4b63e301689f00756da7dbb14215a6d63d4c9793dff964a36

Contents?: true

Size: 1.09 KB

Versions: 18

Compression:

Stored size: 1.09 KB

Contents

require "rubygems"
require_relative "configurator"
require_relative "consumers/mongo_consumer"

module RabbitHutch
  # Controls the consumers that are to be kicked off based on the config file
  class Consumer
    def initialize(consumers)
      @consumers = consumers
    end
    
    # Raised on receipt of a message from RabbitMq and uses the appropriate appender
    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
  end
end

Version data entries

18 entries across 18 versions & 2 rubygems

Version Path
dafiti-rabbit-hutch-0.1.12 lib/consumer.rb
dafiti-rabbit-hutch-0.1.11 lib/consumer.rb
dafiti-rabbit-hutch-0.1.10 lib/consumer.rb
dafiti-rabbit-hutch-0.1.9 lib/consumer.rb
dafiti-rabbit-hutch-0.1.5 lib/consumer.rb
dafiti-rabbit-hutch-0.1.4 lib/consumer.rb
dafiti-rabbit-hutch-0.1.1 lib/consumer.rb
dafiti-rabbit-hutch-0.1.0 lib/consumer.rb
rabbithutch-0.1.5 lib/consumer.rb
rabbithutch-0.1.2 lib/consumer.rb
rabbithutch-0.1.1 lib/consumer.rb
rabbithutch-0.1.0 lib/consumer.rb
rabbithutch-0.0.9 lib/consumer.rb
rabbithutch-0.0.8 lib/consumer.rb
rabbithutch-0.0.7 lib/consumer.rb
rabbithutch-0.0.5 lib/consumer.rb
rabbithutch-0.0.3 lib/consumer.rb
rabbithutch-0.0.2 lib/consumer.rb