Class: Larva::Listener
Instance Attribute Summary collapse
-
#processor ⇒ Object
readonly
Returns the value of attribute processor.
-
#topic_name ⇒ Object
readonly
Returns the value of attribute topic_name.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(topic_name, processor) ⇒ Listener
constructor
A new instance of Listener.
- #listen ⇒ Object
Constructor Details
#initialize(topic_name, processor) ⇒ Listener
Returns a new instance of Listener.
9 10 11 12 |
# File 'lib/larva/listener.rb', line 9 def initialize(topic_name, processor) @topic_name = topic_name @processor = processor end |
Instance Attribute Details
#processor ⇒ Object (readonly)
Returns the value of attribute processor.
8 9 10 |
# File 'lib/larva/listener.rb', line 8 def processor @processor end |
#topic_name ⇒ Object (readonly)
Returns the value of attribute topic_name.
8 9 10 |
# File 'lib/larva/listener.rb', line 8 def topic_name @topic_name end |
Class Method Details
.listen(topic_name, processor) ⇒ Object
4 5 6 |
# File 'lib/larva/listener.rb', line 4 def self.listen(topic_name, processor) new(topic_name, processor).listen end |
Instance Method Details
#listen ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/larva/listener.rb', line 14 def listen queue_name = "#{topic_name}" Propono.config.logger.info "Starting to listen to queue #{queue_name}" Propono.listen_to_queue("#{queue_name}") do |, 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() end end |