java.lang.Object
org.axonframework.messaging.eventhandling.processing.streaming.progress.TokenStoringProgressStrategy
All Implemented Interfaces:
SegmentProgressStrategy

@Internal public final class TokenStoringProgressStrategy extends Object implements SegmentProgressStrategy
Default SegmentProgressStrategy: persists the batch-end token (SegmentProgressContext.lastConsumedToken()) on every commit, so the stored TrackingToken advances to the position consumed by each batch. This is the behaviour to expect when no advanced progress handling is configured.

It schedules no out-of-band work (hasPendingWork() is always false) and acts only within the batch and idle cycles it is invoked on. On an idle cycle onBatchCommit(ProcessingContext) is still invoked on the claim-extension beat, so a token advanced purely by ignored events is caught up then.

Internal API. This class is marked Internal: it is the default implementation of the progress seam and not stable end-user API.

Since:
5.3.0
Author:
Allard Buijze
See Also:
  • Constructor Details

    • TokenStoringProgressStrategy

      public TokenStoringProgressStrategy(SegmentProgressContext context)
      Constructs a TokenStoringProgressStrategy bound to the given context.
      Parameters:
      context - the progress context to persist progress through
  • Method Details

    • onBatchCommit

      public CompletableFuture<Void> onBatchCommit(ProcessingContext processingContext)
      Description copied from interface: SegmentProgressStrategy
      Decides the safe TrackingToken for the current cycle and persists it through SegmentProgressContext.persistProgress(TrackingToken, ProcessingContext), within context. Invoked on the commit of a non-empty batch (so the store commits atomically with the batch), and on an idle cycle to store progress that advanced without a handled batch. May store nothing (for example, when nothing advanced or no persistence is due yet).
      Specified by:
      onBatchCommit in interface SegmentProgressStrategy
      Parameters:
      processingContext - the processing context whose transaction the store participates in
      Returns:
      a CompletableFuture completing when the cycle's persistence (if any) has been applied
    • hasPendingWork

      public boolean hasPendingWork()
      Description copied from interface: SegmentProgressStrategy
      Indicates whether the strategy has out-of-band work that requires a worker cycle even when no events are queued (for example, an asynchronous checkpoint request recorded between cycles). Drives the post-cycle reschedule and lets an idle segment run a commit cycle. Strategies that act only within their batches never schedule out-of-band and return false; this is deliberately not a throttle for idle catch-up stores, which are driven on the claim-extension beat.
      Specified by:
      hasPendingWork in interface SegmentProgressStrategy
      Returns:
      true if a worker cycle is needed for out-of-band work, false otherwise