Class: MultipleMan::Consumers::General

Inherits:
Object
  • Object
show all
Defined in:
lib/multiple_man/consumers/general.rb

Direct Known Subclasses

Seed

Instance Method Summary collapse

Constructor Details

#initialize(subscribers:, queue:, topic:) ⇒ General

Returns a new instance of General.



7
8
9
10
11
# File 'lib/multiple_man/consumers/general.rb', line 7

def initialize(subscribers:, queue:, topic:)
  self.subscribers = subscribers
  @topic = topic
  @queue = queue
end

Instance Method Details

#listenObject



13
14
15
16
17
18
19
20
21
22
# File 'lib/multiple_man/consumers/general.rb', line 13

def listen
  MultipleMan.logger.debug "Starting listeners."
  create_bindings

  queue.subscribe(block: true, manual_ack: true) do |delivery_info, , payload|
    MultipleMan.logger.debug "Processing message for #{delivery_info.routing_key}."
    message = JSON.parse(payload).with_indifferent_access
    receive(delivery_info, , message)
  end
end