Class KafkaTask<T,SELF extends KafkaTask<T,SELF>>
java.lang.Object
io.smallrye.reactive.messaging.kafka.companion.KafkaTask<T,SELF>
- Type Parameters:
T- the type of itemsSELF- the reference to self type
- All Implemented Interfaces:
AutoCloseable,Iterable<T>
- Direct Known Subclasses:
ConsumerTask,ProducerTask
public abstract class KafkaTask<T,SELF extends KafkaTask<T,SELF>>
extends Object
implements Iterable<T>, AutoCloseable
Abstract task for consuming or producing Kafka records provided by the given
Multi
This class leverages AssertSubscriber to subscribe itself to the given multi.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionawaitCompletion(Duration duration) Delegates toAssertSubscriber.awaitCompletion(Duration)awaitCompletion(BiConsumer<Throwable, Boolean> assertion) awaitCompletion(BiConsumer<Throwable, Boolean> assertion, Duration duration) Delegates toAssertSubscriber.awaitCompletion()Delegates toAssertSubscriber.awaitNextItem()awaitNextRecord(Duration duration) Delegates toAssertSubscriber.awaitNextItem(Duration)awaitNextRecords(int number) Delegates toAssertSubscriber.awaitNextItems(int)awaitNextRecords(int number, Duration duration) Delegates toAssertSubscriber.awaitNextItems(int, Duration)awaitNoRecords(Duration duration) Assert no records were received during the given durationawaitRecords(int number) Delegates toAssertSubscriber.awaitItems(int)awaitRecords(int number, Duration duration) Delegates toAssertSubscriber.awaitItems(int, Duration)voidclose()longcount()longio.smallrye.mutiny.Multi<T>getMulti()The list of items that have been received.iterator()longprotected abstract longprotected SELFself()stop()Cancels subscription effectively stoppingstream()protected abstract org.apache.kafka.common.TopicPartitiontopicPartition(T record)
-
Constructor Details
-
KafkaTask
Create a newKafkaTask- Parameters:
multi- the multi to subscribe to
-
-
Method Details
-
getMulti
-
iterator
-
spliterator
- Specified by:
spliteratorin interfaceIterable<T>
-
self
-
count
public long count()- Returns:
- get the number of records received.
-
getFirstRecord
- Returns:
- get the first record received, potentially
nullif no records have been received.
-
getLastRecord
- Returns:
- get the last record received, potentially
nullif no records have been received.
-
getRecords
The list of items that have been received.- Returns:
- the list
-
awaitNextRecord
Delegates toAssertSubscriber.awaitNextItem()- Returns:
- self
-
awaitNextRecord
Delegates toAssertSubscriber.awaitNextItem(Duration)- Returns:
- self
-
awaitNextRecords
Delegates toAssertSubscriber.awaitNextItems(int)- Returns:
- self
-
awaitNextRecords
Delegates toAssertSubscriber.awaitNextItems(int, Duration)- Returns:
- self
-
awaitRecords
Delegates toAssertSubscriber.awaitItems(int)- Returns:
- self
-
awaitRecords
Delegates toAssertSubscriber.awaitItems(int, Duration)- Returns:
- self
-
awaitNoRecords
Assert no records were received during the given duration- Returns:
- self
-
awaitCompletion
- Returns:
- self
-
awaitCompletion
Delegates toAssertSubscriber.awaitCompletion(Duration)- Returns:
- self
-
awaitCompletion
- Returns:
- self
-
awaitCompletion
Delegates toAssertSubscriber.awaitCompletion()- Returns:
- self
-
stop
Cancels subscription effectively stopping- Returns:
- self
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-
firstOffset
public long firstOffset() -
lastOffset
public long lastOffset() -
stream
-
byTopicPartition
-
latestOffsets
-
offset
-
topicPartition
-