Module: Karafka::Pro::Cleaner::Messages::Messages

Defined in:
lib/karafka/pro/cleaner/messages/messages.rb

Overview

Extensions to the messages batch allowing for automatic cleaning of each message after message is processed.

Instance Method Summary collapse

Instance Method Details

#each(clean: false) { ... } ⇒ Object

Note:

Cleaning messages after we’re done with each of them and did not fail does not affect any other functionalities. The only thing that is crucial is to make sure, that if DLQ is used, that we mark each message as consumed when using this API as otherwise a cleaned message may be dispatched and that should never happen

Parameters:

  • clean (Boolean) (defaults to: false)

    do we want to clean each message after we’re done working with it.

Yields:

  • block we want to execute per each message



21
22
23
24
25
26
27
28
29
# File 'lib/karafka/pro/cleaner/messages/messages.rb', line 21

def each(clean: false)
  @messages_array.each do |message|
    yield(message)

    next unless clean

    message.clean!
  end
end