Class: Pushr::Daemon::MessageHandler
- Inherits:
-
Object
- Object
- Pushr::Daemon::MessageHandler
- Defined in:
- lib/pushr/daemon/message_handler.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(queue_name, connection, name, i) ⇒ MessageHandler
constructor
A new instance of MessageHandler.
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(queue_name, connection, name, i) ⇒ MessageHandler
Returns a new instance of MessageHandler.
6 7 8 9 10 11 |
# File 'lib/pushr/daemon/message_handler.rb', line 6 def initialize(queue_name, connection, name, i) @queue_name = queue_name @connection = connection @name = "#{name}: MessageHandler #{i}" Pushr::Daemon.logger.info "[#{@name}] listening to #{@queue_name}" end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
4 5 6 |
# File 'lib/pushr/daemon/message_handler.rb', line 4 def connection @connection end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/pushr/daemon/message_handler.rb', line 4 def name @name end |
Instance Method Details
#start ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/pushr/daemon/message_handler.rb', line 13 def start Thread.new do loop do handle_next break if @stop end end end |
#stop ⇒ Object
22 23 24 |
# File 'lib/pushr/daemon/message_handler.rb', line 22 def stop @stop = true end |