Module: Karafka::Pro::Processing::Strategies::Lrj::Mom
- Includes:
- Default
- Included in:
- Aj::LrjMom, MomVp
- Defined in:
- lib/karafka/pro/processing/strategies/lrj/mom.rb
Overview
Long-Running Job enabled Manual offset management enabled
Constant Summary collapse
- FEATURES =
Features for this strategy
%i[ long_running_job manual_offset_management ].freeze
Instance Method Summary collapse
-
#handle_after_consume ⇒ Object
No offset management, aside from that typical LRJ.
-
#handle_before_enqueue ⇒ Object
We always need to pause prior to doing any jobs for LRJ.
-
#handle_revoked ⇒ Object
We do not un-pause on revokations for LRJ.
Methods included from Default
#handle_before_consume, #handle_consume
Methods included from Karafka::Processing::Strategies::Default
#commit_offsets, #commit_offsets!, #handle_before_consume, #handle_consume, #handle_idle, #handle_shutdown, #mark_as_consumed, #mark_as_consumed!
Methods included from Karafka::Processing::Strategies::Base
#handle_before_consume, #handle_consume, #handle_idle, #handle_shutdown
Instance Method Details
#handle_after_consume ⇒ Object
No offset management, aside from that typical LRJ
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/karafka/pro/processing/strategies/lrj/mom.rb', line 48 def handle_after_consume coordinator.on_finished do || if coordinator.success? coordinator.pause_tracker.reset return if coordinator.manual_pause? unless revoked? || coordinator.manual_seek? seek(.offset + 1, false) end resume else retry_after_pause end end end |
#handle_before_enqueue ⇒ Object
We always need to pause prior to doing any jobs for LRJ
32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/karafka/pro/processing/strategies/lrj/mom.rb', line 32 def handle_before_enqueue super # This ensures that when running LRJ with VP, things operate as expected run only # once for all the virtual partitions collectively coordinator.on_enqueued do # Pause at the first message in a batch. That way in case of a crash, we will not # loose any messages. # # For VP it applies the same way and since VP cannot be used with MOM we should not # have any edge cases here. pause(coordinator.seek_offset, Strategies::Lrj::Default::MAX_PAUSE_TIME, false) end end |
#handle_revoked ⇒ Object
We do not un-pause on revokations for LRJ
67 68 69 70 71 72 73 74 75 76 |
# File 'lib/karafka/pro/processing/strategies/lrj/mom.rb', line 67 def handle_revoked coordinator.on_revoked do coordinator.revoke end Karafka.monitor.instrument('consumer.revoke', caller: self) Karafka.monitor.instrument('consumer.revoked', caller: self) do revoked end end |