Module: Deimos::Consume::MessageConsumption

Extended by:
ActiveSupport::Concern
Includes:
Phobos::Handler
Included in:
Deimos::Consumer
Defined in:
lib/deimos/consume/message_consumption.rb

Overview

Methods used by message-by-message (non-batch) consumers. These consumers are invoked for every individual message.

Instance Method Summary collapse

Instance Method Details

#around_consume(payload, metadata) ⇒ Object

:nodoc:



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/deimos/consume/message_consumption.rb', line 12

def around_consume(payload, )
  decoded_payload = payload.nil? ? nil : payload.dup
   = .dup
  benchmark = Benchmark.measure do
    _with_span do
      [:key] = decode_key([:key]) if self.class.config[:key_configured]
      decoded_payload = decode_message(payload)
      _received_message(decoded_payload, )
      yield(decoded_payload, )
    end
  end
  _handle_success(benchmark.real, decoded_payload, )
rescue StandardError => e
  _handle_error(e, decoded_payload, )
end

#consume(_payload, _metadata) ⇒ Object

Consume incoming messages.

Parameters:

  • _payload (String)
  • _metadata (Hash)

Raises:

  • (NotImplementedError)


31
32
33
# File 'lib/deimos/consume/message_consumption.rb', line 31

def consume(_payload, )
  raise NotImplementedError
end