Package org.apache.kafka.tools.api
Interface RecordReader
- All Superinterfaces:
AutoCloseable,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 `org.apache.kafka.tools.ConsoleProducer`.
-
Method Summary
Modifier and TypeMethodDescriptiondefault voidclose()Closes this reader.default voidConfigure this class with the given key-value pairsIterator<ProducerRecord<byte[], byte[]>> readRecords(InputStream inputStream) read byte array from input stream and then generate an iterator of producer record
-
Method Details
-
configure
Description copied from interface:ConfigurableConfigure this class with the given key-value pairs- Specified by:
configurein interfaceConfigurable
-
readRecords
read byte array from input stream and then generate an iterator of producer record- Parameters:
inputStream-InputStreamof 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:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-