Interface PubSubPosition

All Superinterfaces:
Measurable
All Known Implementing Classes:
ApacheKafkaOffsetPosition, InMemoryPubSubPosition

public interface PubSubPosition extends Measurable
Represents a position of a message in a partition of a topic.
  • Field Details

  • Method Details

    • getNumericOffset

      @Deprecated long getNumericOffset()
      Deprecated.
    • equals

      boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      int hashCode()
      Overrides:
      hashCode in class Object
    • isSymbolic

      default boolean isSymbolic()
    • comparePositionOffline

      default int comparePositionOffline(PubSubPosition other)
      Compares this position with other using only the information carried by the two positions, i.e. without a consumer, broker connection, or topic metadata. Both positions must belong to the same topic-partition.

      The default implementation orders positions by their numeric offsets when both are non-negative and otherwise throws. Implementations whose numeric offset is not meaningful (e.g. log-structured positions without a dense offset) should override this method when their wire format carries enough information to establish an order offline.

      Parameters:
      other - the position to compare against; must not be null
      Returns:
      a negative integer, zero, or a positive integer if this position is respectively before, equal to, or after other
      Throws:
      UnsupportedOperationException - if the two positions cannot be ordered without external state
    • getPositionWireFormat

      PubSubPositionWireFormat getPositionWireFormat()
      Position wrapper is used to wrap the position type and the position value. This is used to serialize and deserialize the position object when sending and receiving it over the wire.
      Returns:
      the position wrapper
    • toWireFormatBuffer

      default ByteBuffer toWireFormatBuffer()
      Returns the serialized wire format bytes of this position.
      Returns:
      byte array representing the position in wire format
    • toWireFormatBytes

      default byte[] toWireFormatBytes()
      Serializes this position to a wire format and returns the result as a byte array. This method bypasses ByteBuffer and directly returns the backing array.
      Returns:
      a byte array representing the serialized wire format of this position
    • toJsonWireFormat

      default PubSubPositionJsonWireFormat toJsonWireFormat()
    • getFactoryClass

      Class<? extends PubSubPositionFactory> getFactoryClass()
      Returns the factory class responsible for creating this position type. This enables strong type checking and reflection-based instantiation without requiring the actual factory instance to be returned.
      Returns:
      the class object of the factory that can construct this position
    • getFactoryClassName

      default String getFactoryClassName()