Class TopicsCompanion

java.lang.Object
io.smallrye.reactive.messaging.kafka.companion.TopicsCompanion

public class TopicsCompanion extends Object
Companion for Topics operations on Kafka broker
  • Constructor Details

    • TopicsCompanion

      public TopicsCompanion(org.apache.kafka.clients.admin.AdminClient adminClient, Duration kafkaApiTimeout)
  • Method Details

    • create

      public void create(Collection<org.apache.kafka.clients.admin.NewTopic> newTopics)
      Parameters:
      newTopics - the set of NewTopics to create
    • create

      public void create(Map<String,Integer> topicPartitions)
      Parameters:
      topicPartitions - the map of topic names to partition counts to create
    • create

      public void create(String topic, int partition)
      Create topic
      Parameters:
      topic - the topic name
      partition - the partition count
    • createAndWait

      public String createAndWait(String topic, int partition)
      Create topic and wait for creation
      Parameters:
      topic - the topic name
      partition - 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 name
      partition - the partition count
      timeout - 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 TopicDescription for the created topic
      Throws:
      IllegalStateException - if the topic is not found at the end of the timeout or retries
    • list

      public Set<String> list()
      Returns:
      the set of topic names
    • describeAll

      public Map<String,org.apache.kafka.clients.admin.TopicDescription> describeAll()
      Returns:
      the map of topic names to topic descriptions
    • describe

      public Map<String,org.apache.kafka.clients.admin.TopicDescription> describe(String... topics)
      Parameters:
      topics - topics to describe
      Returns:
      the map of topic names to topic descriptions
    • clear

      public void clear(String... topics)
      Deletes records from given topics
      Parameters:
      topics - the topic names to clear
    • delete

      public void delete(Collection<String> topics)
      Parameters:
      topics - the collection of topic names to delete
    • delete

      public void delete(String... topics)
      Parameters:
      topics - the topic names to delete