@Singleton @Requires(beans=KafkaDefaultConfiguration.class) public class KafkaConsumerProcessor extends java.lang.Object implements io.micronaut.context.processor.ExecutableMethodProcessor<KafkaListener>, java.lang.AutoCloseable, ConsumerRegistry
A ExecutableMethodProcessor that will process all beans annotated with KafkaListener
and create and subscribe the relevant methods as consumers to Kafka topics.
| Constructor and Description |
|---|
KafkaConsumerProcessor(java.util.concurrent.ExecutorService executorService,
io.micronaut.runtime.ApplicationConfiguration applicationConfiguration,
io.micronaut.context.BeanContext beanContext,
AbstractKafkaConsumerConfiguration defaultConsumerConfiguration,
ConsumerRecordBinderRegistry binderRegistry,
BatchConsumerRecordsBinderRegistry batchBinderRegistry,
SerdeRegistry serdeRegistry,
ProducerRegistry producerRegistry,
KafkaListenerExceptionHandler exceptionHandler)
Creates a new processor using the given
ExecutorService to schedule consumers on. |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
<K,V> org.apache.kafka.clients.consumer.Consumer<K,V> |
getConsumer(java.lang.String id)
Returns a managed Consumer.
|
java.util.Set<java.lang.String> |
getConsumerIds()
The IDs of the available consumers.
|
boolean |
isPaused(java.lang.String id)
Is the consumer with the given ID paused.
|
void |
pause(java.lang.String id)
Pause the consumer for the given ID.
|
void |
process(io.micronaut.inject.BeanDefinition<?> beanDefinition,
io.micronaut.inject.ExecutableMethod<?,?> method) |
void |
resume(java.lang.String id)
Resume the consumer for the given ID.
|
public KafkaConsumerProcessor(@Named(value="consumer")
java.util.concurrent.ExecutorService executorService,
io.micronaut.runtime.ApplicationConfiguration applicationConfiguration,
io.micronaut.context.BeanContext beanContext,
AbstractKafkaConsumerConfiguration defaultConsumerConfiguration,
ConsumerRecordBinderRegistry binderRegistry,
BatchConsumerRecordsBinderRegistry batchBinderRegistry,
SerdeRegistry serdeRegistry,
ProducerRegistry producerRegistry,
KafkaListenerExceptionHandler exceptionHandler)
ExecutorService to schedule consumers on.executorService - The executor serviceapplicationConfiguration - The application configurationbeanContext - The bean contextdefaultConsumerConfiguration - The default consumer configbinderRegistry - The ConsumerRecordBinderRegistrybatchBinderRegistry - The BatchConsumerRecordsBinderRegistryserdeRegistry - The Serde registryproducerRegistry - The ProducerRegistryexceptionHandler - The exception handler to use@Nonnull
public <K,V> org.apache.kafka.clients.consumer.Consumer<K,V> getConsumer(@Nonnull
java.lang.String id)
ConsumerRegistrygetConsumer in interface ConsumerRegistryK - The key generic typeV - The value generic typeid - The id of the producer.@Nonnull public java.util.Set<java.lang.String> getConsumerIds()
ConsumerRegistrygetConsumerIds in interface ConsumerRegistrypublic boolean isPaused(@Nonnull
java.lang.String id)
ConsumerRegistryisPaused in interface ConsumerRegistryid - True it is pausedpublic void pause(@Nonnull
java.lang.String id)
ConsumerRegistryConsumerRegistry.isPaused(String) method to
establish when the consumer has actually been paused.pause in interface ConsumerRegistryid - The id of the consumerpublic void resume(@Nonnull
java.lang.String id)
ConsumerRegistryConsumerRegistry.isPaused(String) method to
establish when the consumer has actually been resumed.resume in interface ConsumerRegistryid - The id of the consumerpublic void process(io.micronaut.inject.BeanDefinition<?> beanDefinition,
io.micronaut.inject.ExecutableMethod<?,?> method)
process in interface io.micronaut.context.processor.AnnotationProcessor<KafkaListener,io.micronaut.inject.ExecutableMethod<?,?>>process in interface io.micronaut.context.processor.ExecutableMethodProcessor<KafkaListener>@PreDestroy public void close()
close in interface java.lang.AutoCloseable