Interface ConsumerRegistry


public interface ConsumerRegistry
A registry for created Kafka consumers. Also provides methods for pausing and resuming consumers.
Since:
1.1
Author:
graemerocher
  • Method Details

    • getConsumer

      @NonNull <K, V> @NonNull Consumer<K,V> getConsumer(@NonNull @NonNull String id)
      Returns a managed Consumer. Note that the consumer should not be interacted with directly from a different thread to the poll loop!
      Type Parameters:
      K - The key generic type
      V - The value generic type
      Parameters:
      id - The id of the producer.
      Returns:
      The consumer
      Throws:
      IllegalArgumentException - If no consumer exists for the given ID
    • getConsumerSubscription

      @NonNull @NonNull Set<String> getConsumerSubscription(@NonNull @NonNull String id)
      Returns a managed Consumer's subscriptions.
      Parameters:
      id - The id of the producer.
      Returns:
      The consumer subscription
      Throws:
      IllegalArgumentException - If no consumer exists for the given ID
    • getConsumerAssignment

      @NonNull @NonNull Set<TopicPartition> getConsumerAssignment(@NonNull @NonNull String id)
      Returns a managed Consumer's assignment info.
      Parameters:
      id - The id of the producer.
      Returns:
      The consumer assignment
      Throws:
      IllegalArgumentException - If no consumer exists for the given ID
    • getConsumerIds

      @NonNull @NonNull Set<String> getConsumerIds()
      The IDs of the available consumers.
      Returns:
      The consumers
    • isPaused

      boolean isPaused(@NonNull @NonNull String id)
      Is the consumer with the given ID paused.
      Parameters:
      id - the consumers id
      Returns:
      True if it is paused
    • isPaused

      boolean isPaused(@NonNull @NonNull String id, @NonNull @NonNull Collection<TopicPartition> topicPartitions)
      Is the consumer with the given ID paused to consume from the given topic partitions.
      Parameters:
      id - the consumers id
      topicPartitions - The topic partitions to check if paused
      Returns:
      True if it is paused for the topic partitions
      Since:
      4.0.1
    • pause

      void pause(@NonNull @NonNull String id)
      Pause the consumer for the given ID. Note that this method will request that the consumer is paused, however does not block until the consumer is actually paused. You can use the isPaused(String) method to establish when the consumer has actually been paused.
      Parameters:
      id - The id of the consumer
    • pause

      void pause(@NonNull @NonNull String id, @NonNull @NonNull Collection<TopicPartition> topicPartitions)
      Pause the consumer for the given ID to consume from the given topic partitions. Note that this method will request that the consumer is paused, however does not block until the consumer is actually paused. You can use the isPaused(String, Collection) method to establish when the consumer has actually been paused for the topic partitions.
      Parameters:
      id - The id of the consumer
      topicPartitions - The topic partitions to pause consuming from
      Since:
      4.0.1
    • resume

      void resume(@NonNull @NonNull String id)
      Resume the consumer for the given ID. Note that this method will request that the consumer is resumed, however does not block until the consumer is actually resumed. You can use the isPaused(String) method to establish when the consumer has actually been resumed.
      Parameters:
      id - The id of the consumer
    • resume

      void resume(@NonNull @NonNull String id, @NonNull @NonNull Collection<TopicPartition> topicPartitions)
      Resume the consumer for the given ID to consume from the given topic partitions. Note that this method will request that the consumer is resumed, however does not block until the consumer is actually resumed. You can use the isPaused(String, Collection) method to establish when the consumer has actually been resumed to consume from the given topic partitions.
      Parameters:
      id - The id of the consumer
      topicPartitions - The topic partitions to pause consuming from
      Since:
      4.0.1