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
FieldsModifier and TypeFieldDescriptionstatic final intPartition value for record without partition assignedConstructor Summary
ConstructorsConstructorDescriptionRecordMetadata(TopicPartition topicPartition, long baseOffset, int batchIndex, long timestamp, int serializedKeySize, int serializedValueSize) Creates a new instance with the provided parameters.Method Summary
Modifier and TypeMethodDescriptionbooleanIndicates whether the record metadata includes the offset.booleanIndicates whether the record metadata includes the timestamp.longoffset()The offset of the record in the topic/partition.intThe partition the record was sent tointThe size of the serialized, uncompressed key in bytes.intThe size of the serialized, uncompressed value in bytes.longThe 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.
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 topartition
public int partition()The partition the record was sent totoString