Sha256: dbc62c4828bbac881e000c2553cd0beb596adf1d4353b0414b03e1997e8051de

Contents?: true

Size: 685 Bytes

Versions: 13

Compression:

Stored size: 685 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.queue_suffix}"
      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

13 entries across 13 versions & 1 rubygems

Version Path
larva-0.9.1 lib/larva/listener.rb
larva-0.9.0 lib/larva/listener.rb
larva-0.8.0 lib/larva/listener.rb
larva-0.7.3 lib/larva/listener.rb
larva-0.7.2 lib/larva/listener.rb
larva-0.7.1 lib/larva/listener.rb
larva-0.7.0 lib/larva/listener.rb
larva-0.6.4 lib/larva/listener.rb
larva-0.6.3 lib/larva/listener.rb
larva-0.6.2 lib/larva/listener.rb
larva-0.6.1 lib/larva/listener.rb
larva-0.6.0 lib/larva/listener.rb
larva-0.5.0 lib/larva/listener.rb