Interface KafkaProducerRecord


public interface KafkaProducerRecord
Represents a proxy to a Kafka ProducerRecord combined with selected data from RecordMetadata. Provides access to details about the topic, partition, key, value, and metadata related to the Kafka record. Acts as an abstraction layer to work with Kafka ProducerRecord objects and their associated metadata.
  • Method Summary

    Modifier and Type
    Method
    Description
    key()
    Gets the deserialized key of the record.
    byte[]
    Gets the value of the last header with the specified key from the record’s headers.
    Gets the underlying metadata represented by this proxy.
    int
    Gets the partition to which the record was sent from the records' metadata.
    Gets the underlying producer record represented by this proxy.
    int
    Gets the size of the serialized key, in bytes.
    int
    Gets the size of the serialized value, in bytes.
    Gets the topic to which the record is sent.
    Gets the deserialized value of the record.
  • Method Details

    • topic

      String topic()
      Gets the topic to which the record is sent.
      Returns:
      the name of the Kafka topic.
    • partition

      int partition()
      Gets the partition to which the record was sent from the records' metadata.
      Returns:
      the partition ID
    • lastHeaderValue

      byte[] lastHeaderValue(String key)
      Gets the value of the last header with the specified key from the record’s headers.
      Parameters:
      key - the key of the desired header.
      Returns:
      the value of the last header with the given key as a byte array, or null if the header does not exist.
    • key

      Object key()
      Gets the deserialized key of the record.
      Returns:
      the key of the record, or null if no key is present.
    • value

      Object value()
      Gets the deserialized value of the record.
      Returns:
      the value of the record, or null if no value is present.
    • serializedKeySize

      int serializedKeySize()
      Gets the size of the serialized key, in bytes.
      Returns:
      the size of the serialized key, or -1 if the key is not present.
    • serializedValueSize

      int serializedValueSize()
      Gets the size of the serialized value, in bytes.
      Returns:
      the size of the serialized value, or -1 if the value is not present.
    • producerRecord

      Object producerRecord()
      Gets the underlying producer record represented by this proxy. This method returns the original Kafka ProducerRecord object.
      Returns:
      the original producer record
    • metadata

      Object metadata()
      Gets the underlying metadata represented by this proxy. This method returns the original Kafka RecordMetadata object.
      Returns:
      the original metadata