Package io.micronaut.configuration.kafka
Class KafkaProducerFactory
java.lang.Object
io.micronaut.configuration.kafka.KafkaProducerFactory
- All Implemented Interfaces:
- ProducerRegistry,- TransactionalProducerRegistry
@Factory
public class KafkaProducerFactory
extends Object
implements ProducerRegistry, TransactionalProducerRegistry
A registry class for Kafka 
Producer instances.- Since:
- 1.0
- Author:
- Graeme Rocher
- 
Constructor SummaryConstructorsConstructorDescriptionKafkaProducerFactory(io.micronaut.context.BeanContext beanContext, SerdeRegistry serdeRegistry, ProducerFactory producerFactory) Default constructor.
- 
Method SummaryModifier and TypeMethodDescriptionvoidClosed the producer.<K,V> Producer<K, V> getProducer(@Nullable io.micronaut.inject.InjectionPoint<KafkaProducer<K, V>> injectionPoint, @Nullable AbstractKafkaProducerConfiguration<K, V> producerConfiguration) Creates a newKafkaProducerfor the given configuration.<K,V> Producer<K, V> getProducer(String id, io.micronaut.core.type.Argument<K> keyType, io.micronaut.core.type.Argument<V> valueType) Returns a managed Producer.<K,V> Producer<K, V> getTransactionalProducer(String id, String transactionalId, io.micronaut.core.type.Argument<K> keyType, io.micronaut.core.type.Argument<V> valueType) Returns a transactional managed Producer.protected voidstop()Shuts down any existing clients.
- 
Constructor Details- 
KafkaProducerFactorypublic KafkaProducerFactory(io.micronaut.context.BeanContext beanContext, SerdeRegistry serdeRegistry, ProducerFactory producerFactory) Default constructor.- Parameters:
- beanContext- The bean context
- serdeRegistry- The serde registry
- producerFactory- The producer factory
 
 
- 
- 
Method Details- 
getProducer@Bean @Any public <K,V> Producer<K,V> getProducer(@Nullable @Nullable io.micronaut.inject.InjectionPoint<KafkaProducer<K, V>> injectionPoint, @Nullable @Parameter @Nullable AbstractKafkaProducerConfiguration<K, V> producerConfiguration) Creates a newKafkaProducerfor the given configuration.- Type Parameters:
- K- The key type
- V- The value type
- Parameters:
- injectionPoint- The injection point used to create the bean
- producerConfiguration- An optional producer configuration
- Returns:
- The consumer
 
- 
stop@PreDestroy protected void stop()Shuts down any existing clients.
- 
getProducerpublic <K,V> Producer<K,V> getProducer(String id, io.micronaut.core.type.Argument<K> keyType, io.micronaut.core.type.Argument<V> valueType) Description copied from interface:ProducerRegistryReturns a managed Producer.- Specified by:
- getProducerin interface- ProducerRegistry
- Type Parameters:
- K- The key generic type
- V- The value generic type
- Parameters:
- id- The id of the producer.
- keyType- The key type
- valueType- The value type
- Returns:
- The producer
 
- 
getTransactionalProducerpublic <K,V> Producer<K,V> getTransactionalProducer(String id, String transactionalId, io.micronaut.core.type.Argument<K> keyType, io.micronaut.core.type.Argument<V> valueType) Description copied from interface:TransactionalProducerRegistryReturns a transactional managed Producer.- Specified by:
- getTransactionalProducerin interface- TransactionalProducerRegistry
- Type Parameters:
- K- The key generic type
- V- The value generic type
- Parameters:
- id- The client id of the producer.
- transactionalId- The transactional id of the producer.
- keyType- The key type
- valueType- The value type
- Returns:
- The producer
 
- 
closeDescription copied from interface:TransactionalProducerRegistryClosed the producer. Should be used for cases whenProducerFencedExceptionis thrown.- Specified by:
- closein interface- TransactionalProducerRegistry
- Parameters:
- producer- The producer
 
 
-