Class RecordMetadata


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

      Fields 
      Modifier and Type Field Description
      static int UNKNOWN_PARTITION
      Partition value for record without partition assigned
    • Constructor Summary

      Constructors 
      Constructor Description
      RecordMetadata​(TopicPartition topicPartition, long baseOffset, long relativeOffset)
      For kafka-0.9.0 backward compatibility
      RecordMetadata​(TopicPartition topicPartition, long baseOffset, long relativeOffset, long timestamp, long checksum, int serializedKeySize, int serializedValueSize)
      Deprecated.
      As of 0.11.0.
      RecordMetadata​(TopicPartition topicPartition, long baseOffset, long relativeOffset, long timestamp, java.lang.Long checksum, int serializedKeySize, int serializedValueSize)  
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      long checksum()
      Deprecated.
      As of Kafka 0.11.0.
      boolean hasOffset()
      Indicates whether the record metadata includes the offset.
      boolean hasTimestamp()
      Indicates whether the record metadata includes the timestamp.
      long offset()
      The offset of the record in the topic/partition.
      int partition()
      The partition the record was sent to
      int serializedKeySize()
      The size of the serialized, uncompressed key in bytes.
      int serializedValueSize()
      The size of the serialized, uncompressed value in bytes.
      long timestamp()
      The timestamp of the record in the topic/partition.
      java.lang.String topic()
      The topic the record was appended to
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • 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)
        For kafka-0.9.0 backward compatibility
      • RecordMetadata

        public RecordMetadata​(TopicPartition topicPartition,
                              long baseOffset,
                              long relativeOffset,
                              long timestamp,
                              java.lang.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 java.lang.String topic()
        The topic the record was appended to
      • partition

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

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object