Sha256: 6113050c7cff5ffed4bfdfb7001ba1308657d327231b001f1a7bc360339b7749

Contents?: true

Size: 742 Bytes

Versions: 4

Compression:

Stored size: 742 Bytes

Contents

module Larva
  class Listener

    def self.listen(topic_name, processor, queue_suffix)
      new(topic_name, processor, queue_suffix).listen
    end

    attr_reader :topic_name, :processor, :queue_suffix
    def initialize(topic_name, processor, queue_suffix)
      @topic_name = topic_name
      @processor = processor
      @queue_suffix = queue_suffix
    end

    def listen
      Propono.config.logger.info "Starting to listen to queue #{topic_name}#{queue_suffix}"
      Propono.listen_to_queue("#{topic_name}#{queue_suffix}") do |message, context|
        Propono.config.logger.context_id = context[:id]
        Propono.config.logger.info "Received message: #{message}"
        processor.process(message)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
larva-0.4.1 lib/larva/listener.rb
larva-0.4.0 lib/larva/listener.rb
larva-0.3.0 lib/larva/listener.rb
larva-0.1.0 lib/larva/listener.rb