Class Position

java.lang.Object
io.fluxcapacitor.common.api.tracking.Position

public class Position extends Object
Represents the tracking state of a consumer, i.e. the last known indexes of consumed messages per segment.

Flux Capacitor segments the message log to support parallel consumption. A Position stores the most recent message index processed for each segment. This allows precise resumption of message consumption on restarts or rebalances.

A Position is an immutable structure and may be merged or queried to support multi-segment tracking.

  • Field Details

    • MAX_SEGMENT

      public static int MAX_SEGMENT
    • FULL_SEGMENT

      public static int[] FULL_SEGMENT
  • Constructor Details

    • Position

      public Position(long index)
    • Position

      public Position(int[] segment, long index)
  • Method Details

    • newPosition

      public static Position newPosition()
      Creates an empty position.
    • getIndex

      public Optional<Long> getIndex(int segment)
    • isNew

      public boolean isNew(int[] segment)
    • lowestIndexForSegment

      public Optional<Long> lowestIndexForSegment(int[] segment)
    • merge

      public Position merge(Position newPosition)
      Merges two Position objects by taking the highest known index per segment.
    • splitInSegments

      public Map<int[],Long> splitInSegments()
      Splits the position map into contiguous segment ranges that share the same index.
    • isNewMessage

      public boolean isNewMessage(SerializedMessage message)
    • isNewIndex

      public boolean isNewIndex(int segment, Long messageIndex)