Class OffsetAndMetadata
java.lang.Object
org.apache.kafka.clients.consumer.OffsetAndMetadata
- All Implemented Interfaces:
- Serializable
The Kafka offset commit API allows users to provide additional metadata (in the form of a string)
 when an offset is committed. This can be useful (for example) to store information about which
 node made the commit, what time the commit was made, etc.
- See Also:
- 
Constructor SummaryConstructorsConstructorDescriptionOffsetAndMetadata(long offset) Construct a new OffsetAndMetadata object for committing throughKafkaConsumer.OffsetAndMetadata(long offset, String metadata) Construct a new OffsetAndMetadata object for committing throughKafkaConsumer.OffsetAndMetadata(long offset, Optional<Integer> leaderEpoch, String metadata) Construct a new OffsetAndMetadata object for committing throughKafkaConsumer.
- 
Method Summary
- 
Constructor Details- 
OffsetAndMetadataConstruct a new OffsetAndMetadata object for committing throughKafkaConsumer.- Parameters:
- offset- The offset to be committed
- leaderEpoch- Optional leader epoch of the last consumed record
- metadata- Non-null metadata
 
- 
OffsetAndMetadataConstruct a new OffsetAndMetadata object for committing throughKafkaConsumer.- Parameters:
- offset- The offset to be committed
- metadata- Non-null metadata
 
- 
OffsetAndMetadatapublic OffsetAndMetadata(long offset) Construct a new OffsetAndMetadata object for committing throughKafkaConsumer. The metadata associated with the commit will be empty.- Parameters:
- offset- The offset to be committed
 
 
- 
- 
Method Details- 
offsetpublic long offset()
- 
metadata
- 
leaderEpochGet the leader epoch of the previously consumed record (if one is known). Log truncation is detected if there exists a leader epoch which is larger than this epoch and begins at an offset earlier than the committed offset.- Returns:
- the leader epoch or empty if not known
 
- 
equals
- 
hashCodepublic int hashCode()
- 
toString
 
-