Class TopicsCompanion
java.lang.Object
io.smallrye.reactive.messaging.kafka.companion.TopicsCompanion
Companion for Topics operations on Kafka broker
-
Constructor Summary
ConstructorsConstructorDescriptionTopicsCompanion(org.apache.kafka.clients.admin.AdminClient adminClient, Duration kafkaApiTimeout) -
Method Summary
Modifier and TypeMethodDescriptionvoidDeletes records from given topicsvoidCreate topicvoidcreate(Collection<org.apache.kafka.clients.admin.NewTopic> newTopics) voidcreateAndWait(String topic, int partition) Create topic and wait for creationorg.apache.kafka.clients.admin.TopicDescriptioncreateAndWait(String topic, int partition, Duration timeout) Create topic and wait for creationvoidvoiddelete(Collection<String> topics) list()io.smallrye.mutiny.Uni<org.apache.kafka.clients.admin.TopicDescription>waitForTopic(String topic) Wait for topic.
-
Constructor Details
-
TopicsCompanion
public TopicsCompanion(org.apache.kafka.clients.admin.AdminClient adminClient, Duration kafkaApiTimeout)
-
-
Method Details
-
create
- Parameters:
newTopics- the set ofNewTopics to create
-
create
- Parameters:
topicPartitions- the map of topic names to partition counts to create
-
create
Create topic- Parameters:
topic- the topic namepartition- the partition count
-
createAndWait
Create topic and wait for creation- Parameters:
topic- the topic namepartition- the partition count- Returns:
- the name of the created topic
-
createAndWait
public org.apache.kafka.clients.admin.TopicDescription createAndWait(String topic, int partition, Duration timeout) Create topic and wait for creation- Parameters:
topic- the topic namepartition- the partition counttimeout- timeout for topic to be created- Returns:
- the description of the created topic
-
waitForTopic
public io.smallrye.mutiny.Uni<org.apache.kafka.clients.admin.TopicDescription> waitForTopic(String topic) Wait for topic. Waits at most the duration of the given kafkaApiTimeout, with 10 retries.- Parameters:
topic- name- Returns:
- the Uni of the
TopicDescriptionfor the created topic - Throws:
IllegalStateException- if the topic is not found at the end of the timeout or retries
-
list
- Returns:
- the set of topic names
-
describeAll
- Returns:
- the map of topic names to topic descriptions
-
describe
- Parameters:
topics- topics to describe- Returns:
- the map of topic names to topic descriptions
-
clear
Deletes records from given topics- Parameters:
topics- the topic names to clear
-
delete
- Parameters:
topics- the collection of topic names to delete
-
delete
- Parameters:
topics- the topic names to delete
-