Class: NulogyMessageBusConsumer::Steps::StreamMessages

Inherits:
Object
  • Object
show all
Defined in:
lib/nulogy_message_bus_consumer/steps/stream_messages.rb

Instance Method Summary collapse

Constructor Details

#initialize(logger) ⇒ StreamMessages

Returns a new instance of StreamMessages.



4
5
6
# File 'lib/nulogy_message_bus_consumer/steps/stream_messages.rb', line 4

def initialize(logger)
  @logger = logger
end

Instance Method Details

#call(kafka_consumer:, **_) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/nulogy_message_bus_consumer/steps/stream_messages.rb', line 8

def call(kafka_consumer:, **_)
  kafka_consumer.each do |kafka_message|
    yield(
      message: Message.from_kafka(kafka_message),
      kafka_message: kafka_message
    )
  end
rescue => e
  @logger.error(JSON.dump({
    event: "message_processing_errored",
    class: e.class,
    message: e.message
  }))

  raise
end