Interface MessageId

All Superinterfaces:
Comparable<MessageId>

public interface MessageId extends Comparable<MessageId>
Opaque, immutable identifier for a message within a topic.

No internal structure (ledger ID, entry ID, partition index) is exposed. Message IDs can be serialized to bytes for external storage and restored later.

  • Method Summary

    Modifier and Type
    Method
    Description
    static MessageId
    Sentinel representing the oldest available message in the topic.
    static MessageId
    fromByteArray(byte[] data)
    Deserialize a message ID from bytes previously produced by toByteArray().
    static MessageId
    Sentinel representing the next message to be published (i.e., the end of the topic).
    byte[]
    Serialize this message ID to a byte array for external storage.

    Methods inherited from interface java.lang.Comparable

    compareTo
  • Method Details

    • toByteArray

      byte[] toByteArray()
      Serialize this message ID to a byte array for external storage.
      Returns:
      a byte array representation of this message ID that can be restored via fromByteArray(byte[])
    • fromByteArray

      static MessageId fromByteArray(byte[] data) throws IOException
      Deserialize a message ID from bytes previously produced by toByteArray().
      Parameters:
      data - the byte array previously obtained from toByteArray()
      Returns:
      the deserialized MessageId
      Throws:
      IOException - if the byte array is malformed or cannot be deserialized
    • earliest

      static MessageId earliest()
      Sentinel representing the oldest available message in the topic.
      Returns:
      a sentinel MessageId representing the earliest position in the topic
    • latest

      static MessageId latest()
      Sentinel representing the next message to be published (i.e., the end of the topic).
      Returns:
      a sentinel MessageId representing the latest position in the topic