Class RecordMetadata
java.lang.Object
org.apache.kafka.clients.producer.RecordMetadata
The metadata for a record that has been acknowledged by the server
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Partition value for record without partition assigned -
Constructor Summary
ConstructorDescriptionRecordMetadata
(TopicPartition topicPartition, long baseOffset, int batchIndex, long timestamp, int serializedKeySize, int serializedValueSize) Creates a new instance with the provided parameters.RecordMetadata
(TopicPartition topicPartition, long baseOffset, long batchIndex, long timestamp, Long checksum, int serializedKeySize, int serializedValueSize) Deprecated.use constructor without `checksum` parameter. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Indicates whether the record metadata includes the offset.boolean
Indicates whether the record metadata includes the timestamp.long
offset()
The offset of the record in the topic/partition.int
The partition the record was sent toint
The size of the serialized, uncompressed key in bytes.int
The size of the serialized, uncompressed value in bytes.long
The timestamp of the record in the topic/partition.topic()
The topic the record was appended totoString()
-
Field Details
-
UNKNOWN_PARTITION
public static final int UNKNOWN_PARTITIONPartition value for record without partition assigned- See Also:
-
-
Constructor Details
-
RecordMetadata
public RecordMetadata(TopicPartition topicPartition, long baseOffset, int batchIndex, long timestamp, int serializedKeySize, int serializedValueSize) Creates a new instance with the provided parameters. -
RecordMetadata
@Deprecated public RecordMetadata(TopicPartition topicPartition, long baseOffset, long batchIndex, long timestamp, Long checksum, int serializedKeySize, int serializedValueSize) Deprecated.use constructor without `checksum` parameter. This constructor will be removed in Apache Kafka 4.0 (deprecated since 3.0).Creates a new instance with the provided parameters.
-
-
Method Details
-
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.
-
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
The topic the record was appended to -
partition
public int partition()The partition the record was sent to -
toString
-