Interface RecordReader

All Superinterfaces:
AutoCloseable, Closeable, org.apache.kafka.common.Configurable

public interface RecordReader extends Closeable, org.apache.kafka.common.Configurable
Typical implementations of this interface convert data from an `InputStream` received via `readRecords` into a iterator of `ProducerRecord` instance. Note that implementations must have a public nullary constructor. This is used by the `org.apache.kafka.tools.ConsoleProducer`.
  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    Closes this reader.
    default void
    configure(Map<String,?> configs)
     
    Iterator<org.apache.kafka.clients.producer.ProducerRecord<byte[],byte[]>>
    readRecords(InputStream inputStream)
    read byte array from input stream and then generate an iterator of producer record
  • Method Details

    • configure

      default void configure(Map<String,?> configs)
      Specified by:
      configure in interface org.apache.kafka.common.Configurable
    • readRecords

      Iterator<org.apache.kafka.clients.producer.ProducerRecord<byte[],byte[]>> readRecords(InputStream inputStream)
      read byte array from input stream and then generate an iterator of producer record
      Parameters:
      inputStream - InputStream of messages. the implementation does not need to close the input stream.
      Returns:
      an iterator of producer record. It should implement following rules. 1) the hasNext() method must be idempotent. 2) the convert error should be thrown by next() method.
    • close

      default void close()
      Closes this reader. This method is invoked if the iterator from readRecords either has no more records or throws exception.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable