Interface TrackingStrategy

All Superinterfaces:
AutoCloseable, Closeable
All Known Implementing Classes:
DefaultTrackingStrategy

public interface TrackingStrategy extends Closeable
A TrackingStrategy defines how a Tracker consumes messages from a message log or distributed segment space.

This interface enables pluggable strategies for message consumption and parallelism. Depending on the configuration and type of tracker, a strategy may either:

  • Fetch and supply message batches directly from the message store (tailing a log), or
  • Negotiate segment claims and delegate message retrieval to the tracker itself (client-side tracking).

Tracking strategies are a key part of Flux's support for distributed, fault-tolerant, and parallel message handling.

Responsibilities

A TrackingStrategy is responsible for:

Implementations should be thread-safe and able to handle dynamic tracker registration and segment rebalancing.

  • Method Summary

    Modifier and Type
    Method
    Description
    void
    claimSegment(Tracker tracker, PositionStore positionStore)
    Claims one or more message segments for the given tracker.
    void
    Closes the tracking strategy and releases any underlying resources.
    void
    disconnectTrackers(Predicate<Tracker> predicate, boolean sendFinalBatch)
    Disconnects trackers that match the provided filter.
    void
    getBatch(Tracker tracker, PositionStore positionStore)
    Requests a new batch of messages for the given tracker.
  • Method Details

    • getBatch

      void getBatch(Tracker tracker, PositionStore positionStore)
      Requests a new batch of messages for the given tracker.

      This method is typically invoked by the Tracker when it is ready to handle more messages. Depending on the strategy, this method may:

      • Fetch messages directly from a MessageStore and deliver them to the tracker (e.g. for log tailing), or
      • Suspend the tracker until messages become available
      Parameters:
      tracker - the tracker requesting a batch
      positionStore - to fetch or update tracking positions
    • claimSegment

      void claimSegment(Tracker tracker, PositionStore positionStore)
      Claims one or more message segments for the given tracker.

      This method is invoked when segment-based partitioning is enabled. It ensures that each segment is only claimed by a single tracker at a time and may release conflicting claims if necessary.

      Parameters:
      tracker - the tracker attempting to claim a segment
      positionStore - to fetch tracking positions
    • disconnectTrackers

      void disconnectTrackers(Predicate<Tracker> predicate, boolean sendFinalBatch)
      Disconnects trackers that match the provided filter.

      This is typically used during client shutdown, reconfiguration, or error handling to forcibly remove trackers from the strategy's internal registry.

      Parameters:
      predicate - filter for matching trackers to disconnect
      sendFinalBatch - if true, a final empty batch should be sent to each disconnected tracker to allow graceful termination
    • close

      void close()
      Closes the tracking strategy and releases any underlying resources.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable