Module: Karafka::Routing::Features::ActiveJob::Builder

Included in:
Proxy
Defined in:
lib/karafka/routing/features/active_job/builder.rb

Overview

Routing extensions for ActiveJob

Instance Method Summary collapse

Instance Method Details

#active_job_topic(name, &block) ⇒ Object

This method simplifies routes definition for ActiveJob topics / queues by auto-injecting the consumer class

Parameters:

  • name (String, Symbol)

    name of the topic where ActiveJobs jobs should go

  • block (Proc)

    block that we can use for some extra configuration



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/karafka/routing/features/active_job/builder.rb', line 14

def active_job_topic(name, &block)
  topic(name) do
    consumer App.config.internal.active_job.consumer_class
    active_job true

    # This is handled by our custom ActiveJob consumer
    # Without this, default behaviour would cause messages to skip upon shutdown as the
    # offset would be committed for the last message
    manual_offset_management true

    next unless block

    instance_eval(&block)
  end
end