Package io.micronaut.configuration.kafka
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 Summary
Modifier and TypeMethodDescription<K,
V> @NonNull Consumer<K, V> getConsumer
(@NonNull String id) Returns a managed Consumer.@NonNull Set<TopicPartition>
getConsumerAssignment
(@NonNull String id) Returns a managed Consumer's assignment info.The IDs of the available consumers.getConsumerSubscription
(@NonNull String id) Returns a managed Consumer's subscriptions.boolean
Is the consumer with the given ID paused.boolean
isPaused
(@NonNull String id, @NonNull Collection<TopicPartition> topicPartitions) Is the consumer with the given ID paused to consume from the given topic partitions.void
Pause the consumer for the given ID.void
pause
(@NonNull String id, @NonNull Collection<TopicPartition> topicPartitions) Pause the consumer for the given ID to consume from the given topic partitions.void
Resume the consumer for the given ID.void
resume
(@NonNull String id, @NonNull Collection<TopicPartition> topicPartitions) Resume the consumer for the given ID to consume from the given topic partitions.
-
Method Details
-
getConsumer
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 typeV
- 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
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
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
The IDs of the available consumers.- Returns:
- The consumers
-
isPaused
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 idtopicPartitions
- The topic partitions to check if paused- Returns:
- True if it is paused for the topic partitions
- Since:
- 4.0.1
-
pause
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 theisPaused(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 theisPaused(String, Collection)
method to establish when the consumer has actually been paused for the topic partitions.- Parameters:
id
- The id of the consumertopicPartitions
- The topic partitions to pause consuming from- Since:
- 4.0.1
-
resume
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 theisPaused(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 theisPaused(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 consumertopicPartitions
- The topic partitions to pause consuming from- Since:
- 4.0.1
-