Sha256: dc4292c398a7c747c20457f4cbf497761f0cc920a4f630dbd57b0d75fdd4f447

Contents?: true

Size: 706 Bytes

Versions: 7

Compression:

Stored size: 706 Bytes

Contents

module Larva
  class Listener

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

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

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

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
larva-1.3.0 lib/larva/listener.rb
larva-1.2.0 lib/larva/listener.rb
larva-1.1.3 lib/larva/listener.rb
larva-1.1.2 lib/larva/listener.rb
larva-1.1.1 lib/larva/listener.rb
larva-1.1.0 lib/larva/listener.rb
larva-1.0.1 lib/larva/listener.rb