Interface RecordReader

All Superinterfaces:
AutoCloseable, Closeable, Configurable

public interface RecordReader extends Closeable, 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 `kafka.tools.ConsoleProducer`.
  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    Closes this reader.
    default void
    configure(Map<String,?> configs)
    Configure this class with the given key-value pairs
    Iterator<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)
      Description copied from interface: Configurable
      Configure this class with the given key-value pairs
      Specified by:
      configure in interface Configurable
    • readRecords

      Iterator<ProducerRecord<byte[],byte[]>> readRecords(InputStream inputStream)
      read byte array from input stream and then generate an iterator of producer record
      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