Sha256: 9ce1cf674d7c36dd457fc32d3abb3e9efb7e43a9efaec9b3e9275c093f89c8ec

Contents?: true

Size: 606 Bytes

Versions: 2

Compression:

Stored size: 606 Bytes

Contents

# -*- encoding : utf-8 -*-
module Untied
  module Consumer
    class Worker
      def initialize(opts)
        @channel = opts[:channel]
        @queue_name = opts[:queue_name] || ""
        @consumer = opts[:consumer] || Processor.new
        @exchange = opts[:exchange]

        Consumer.config.logger.info "Worker initialized and listening"
      end

      def start
        @channel.queue(@queue_name, :exclusive => true) do |queue|
          queue.bind(@exchange, :routing_key => "untied.#").subscribe do |h,p|
            @consumer.process(h,p)
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
untied-consumer-0.0.2 lib/untied-consumer/worker.rb
untied-consumer-0.0.1 lib/untied-consumer/worker.rb