Module: Karafka::Pro::Routing::Features::DeadLetterQueue::Topic

Defined in:
lib/karafka/pro/routing/features/dead_letter_queue/topic.rb

Overview

Expansions to the topic API in DLQ

Instance Method Summary collapse

Instance Method Details

#dead_letter_queue(strategy: nil, **args) ⇒ Object

(same as in OSS) should be applied

Parameters:

  • strategy (#call, nil) (defaults to: nil)

    Strategy we want to use or nil if a default strategy

  • args (Hash)

    OSS DLQ arguments



24
25
26
27
28
29
30
31
32
33
# File 'lib/karafka/pro/routing/features/dead_letter_queue/topic.rb', line 24

def dead_letter_queue(strategy: nil, **args)
  return @dead_letter_queue if @dead_letter_queue

  super(**args).tap do |config|
    # If explicit strategy is not provided, use the default approach from OSS
    config.strategy = strategy || lambda do |_errors_tracker, attempt|
      attempt > config.max_retries ? :dispatch : :retry
    end
  end
end