Class: DataCollector::Input::Queue

Inherits:
Generic
  • Object
show all
Defined in:
lib/data_collector/input/queue.rb

Instance Method Summary collapse

Methods inherited from Generic

#on_message, #pause, #paused?, #run, #stop, #stopped?

Constructor Details

#initialize(uri, options = {}) ⇒ Queue

Returns a new instance of Queue.



9
10
11
12
13
14
15
# File 'lib/data_collector/input/queue.rb', line 9

def initialize(uri, options = {})
  super

  if running?
    create_queue unless @queue
  end
end

Instance Method Details

#running?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/data_collector/input/queue.rb', line 17

def running?
  @listener.open?
end

#send(route, message) ⇒ Object



21
22
23
24
25
# File 'lib/data_collector/input/queue.rb', line 21

def send(route, message)
  if running?
    @exchange.publish(message, routing_key: route)
  end
end