Class: Pushr::Daemon::MessageHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/pushr/daemon/message_handler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#connectionObject (readonly)

Returns the value of attribute connection.



4
5
6
# File 'lib/pushr/daemon/message_handler.rb', line 4

def connection
  @connection
end

#nameObject (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

#startObject



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

#stopObject



22
23
24
# File 'lib/pushr/daemon/message_handler.rb', line 22

def stop
  @stop = true
end