Class: Karafka::ActiveJob::Consumer

Inherits:
BaseConsumer show all
Defined in:
lib/karafka/active_job/consumer.rb

Overview

This is the consumer for ActiveJob that eats the messages enqueued with it one after another. It marks the offset after each message, so we make sure, none of the jobs is executed twice

Direct Known Subclasses

Pro::ActiveJob::Consumer

Instance Attribute Summary

Attributes inherited from BaseConsumer

#client, #coordinator, #id, #messages, #producer

Instance Method Summary collapse

Methods inherited from BaseConsumer

#initialize, #inspect, #on_after_consume, #on_before_consume, #on_before_schedule_consume, #on_before_schedule_eofed, #on_before_schedule_idle, #on_before_schedule_revoked, #on_before_schedule_shutdown, #on_consume, #on_eofed, #on_idle, #on_initialized, #on_revoked, #on_shutdown, #on_wrap

Constructor Details

This class inherits a constructor from Karafka::BaseConsumer

Instance Method Details

#consumeObject

Note:

ActiveJob does not support batches, so we just run one message after another

Executes the ActiveJob logic



15
16
17
18
19
20
21
22
23
# File 'lib/karafka/active_job/consumer.rb', line 15

def consume
  messages.each do |message|
    break if ::Karafka::App.stopping?

    consume_job(message)

    mark_as_consumed(message)
  end
end