Interface TrackingToken

All Known Subinterfaces:
WrappedToken
All Known Implementing Classes:
ConfigToken, GapAwareTrackingToken, GapAwareTrackingToken, GlobalSequenceTrackingToken, GlobalSequenceTrackingToken, MergedTrackingToken, MultiSourceTrackingToken, ReplayToken

public interface TrackingToken
Tag interface identifying a token that is used to identify the position of an event in an event stream. Event processors use this token to keep track of the events they have processed and still need to process.
Author:
Rene de Waele
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Indicates whether this token covers the other token completely.
    Returns a token that represents the lower bound between this and the other token.
    default OptionalLong
    Return the estimated relative position this token represents.
    default boolean
    Indicates whether this token is at the exact same spot in the event stream as the other token.
    Returns the token that represents the furthest possible position in a stream that either this token or the given other represents.
  • Method Details

    • lowerBound

      TrackingToken lowerBound(TrackingToken other)
      Returns a token that represents the lower bound between this and the other token. Effectively, the returned token will cause messages not received by both this and the other token to be redelivered.
      Parameters:
      other - The token to compare to this one
      Returns:
      The token representing the lower bound of the two
    • upperBound

      TrackingToken upperBound(TrackingToken other)
      Returns the token that represents the furthest possible position in a stream that either this token or the given other represents. Effectively, this means this token will only deliver messages that neither this, nor the other have been received.
      Parameters:
      other - The token to compare this token to
      Returns:
      a token that represents the furthest position of this or the other stream
    • covers

      boolean covers(TrackingToken other)
      Indicates whether this token covers the other token completely. That means that this token represents a position in a stream that has received all of the messages that a stream represented by the other token has received.

      Note that this operation is only safe when comparing tokens obtained from messages from the same StreamableMessageSource.

      Parameters:
      other - The token to compare to this one
      Returns:
      true if this token covers the other, otherwise false
    • position

      default OptionalLong position()
      Return the estimated relative position this token represents. In case no estimation can be given an OptionalLong.empty() will be returned.
      Returns:
      the estimated relative position of this token
    • samePositionAs

      default boolean samePositionAs(TrackingToken other)
      Indicates whether this token is at the exact same spot in the event stream as the other token.

      This method is particularly useful when comparing tokens from different points in time, such as during replay detection, where token implementations may naturally differ.

      By default, this method checks bidirectional coverage: this.covers(other) && other.covers(this), which ensures both tokens are at the same position.

      Parameters:
      other - The token to validate against this token.
      Returns:
      true if this token is at the same location as the other token, otherwise false. Returns false if other is null.
      Since:
      4.12.3
      See Also: