Package io.debezium.kafka
Interface KafkaCluster.InteractiveConsumer<K,V>
- Type Parameters:
K- the type of keyV- the type of value
- All Superinterfaces:
AutoCloseable,Closeable
- Enclosing class:
- KafkaCluster
A simple interactive Kafka consumer for use with the cluster.
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Asynchronously close this consumer's connection to Kafka and begin to clean up all resources.Block until a record can be read from this consumer's topic, and return the record.nextRecord(long timeout, TimeUnit unit) Block until a record can be read from this consumer's topic or until the timeout occurs, and if a record was read return the record.default VBlock until a record can be read from this consumer's topic, and return the value in that record.default VBlock until a record can be read from this consumer's topic or until the timeout occurs, and if a record was read return the value in that record.stream()Obtain a stream to consume the input messages.Obtain a stream over all of accumulated input messages.
-
Method Details
-
nextValue
Block until a record can be read from this consumer's topic, and return the value in that record.- Returns:
- the value; never null
- Throws:
InterruptedException- if the thread is interrupted while blocking
-
nextRecord
Block until a record can be read from this consumer's topic, and return the record.- Returns:
- the record; never null
- Throws:
InterruptedException- if the thread is interrupted while blocking
-
nextValue
Block until a record can be read from this consumer's topic or until the timeout occurs, and if a record was read return the value in that record.- Parameters:
timeout- the maximum amount of time to block to wait for a recordunit- the unit of time for thetimeout- Returns:
- the value, or null if the method timed out
- Throws:
InterruptedException- if the thread is interrupted while blocking
-
nextRecord
org.apache.kafka.clients.consumer.ConsumerRecord<K,V> nextRecord(long timeout, TimeUnit unit) throws InterruptedException Block until a record can be read from this consumer's topic or until the timeout occurs, and if a record was read return the record.- Parameters:
timeout- the maximum amount of time to block to wait for a recordunit- the unit of time for thetimeout- Returns:
- the record, or null if the method timed out
- Throws:
InterruptedException- if the thread is interrupted while blocking
-
stream
Obtain a stream to consume the input messages. This method can be used in place of repeated calls to thenext...()methods.- Returns:
- the stream of all messages.
-
streamAll
Obtain a stream over all of accumulated input messages. This method can be called multiple times, and each time the resulting stream will operate over all messages that received by this consumer, and is completely independent of thestream(),nextRecord(),nextRecord(long, TimeUnit),nextValue()andnextValue(long, TimeUnit)methods.- Returns:
- the stream of all messages.
-
close
void close()Asynchronously close this consumer's connection to Kafka and begin to clean up all resources.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-