Class RecordMetadata


  • public final class RecordMetadata
    extends Object
    The metadata for a record that has been acknowledged by the server
    • Field Detail

      • UNKNOWN_PARTITION

        public static final int UNKNOWN_PARTITION
        Partition value for record without partition assigned
        See Also:
        Constant Field Values
    • Constructor Detail

      • RecordMetadata

        public RecordMetadata​(TopicPartition topicPartition,
                              long baseOffset,
                              long relativeOffset,
                              long timestamp,
                              Long checksum,
                              int serializedKeySize,
                              int serializedValueSize)
    • Method Detail

      • hasOffset

        public boolean hasOffset()
        Indicates whether the record metadata includes the offset.
        Returns:
        true if the offset is included in the metadata, false otherwise.
      • offset

        public long offset()
        The offset of the record in the topic/partition.
        Returns:
        the offset of the record, or -1 if {hasOffset()} returns false.
      • hasTimestamp

        public boolean hasTimestamp()
        Indicates whether the record metadata includes the timestamp.
        Returns:
        true if a valid timestamp exists, false otherwise.
      • timestamp

        public long timestamp()
        The timestamp of the record in the topic/partition.
        Returns:
        the timestamp of the record, or -1 if the {hasTimestamp()} returns false.
      • checksum

        @Deprecated
        public long checksum()
        Deprecated.
        As of Kafka 0.11.0. Because of the potential for message format conversion on the broker, the computed checksum may not match what was stored on the broker, or what will be returned to the consumer. It is therefore unsafe to depend on this checksum for end-to-end delivery guarantees. Additionally, message format v2 does not include a record-level checksum (for performance, the record checksum was replaced with a batch checksum). To maintain compatibility, a partial checksum computed from the record timestamp, serialized key size, and serialized value size is returned instead, but this should not be depended on for end-to-end reliability.
        The checksum (CRC32) of the record.
      • serializedKeySize

        public int serializedKeySize()
        The size of the serialized, uncompressed key in bytes. If key is null, the returned size is -1.
      • serializedValueSize

        public int serializedValueSize()
        The size of the serialized, uncompressed value in bytes. If value is null, the returned size is -1.
      • topic

        public String topic()
        The topic the record was appended to
      • partition

        public int partition()
        The partition the record was sent to