Sha256: f84ba51635ff1192317c14f70934e7a44644eec3090aee051f6245fddbf87512

Contents?: true

Size: 655 Bytes

Versions: 2

Compression:

Stored size: 655 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]
        Propono.config.logger.info "Received message: #{message}"
        processor.process(message)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
larva-1.0.0 lib/larva/listener.rb
larva-0.9.2 lib/larva/listener.rb