@Factory public class KafkaProducerFactory extends java.lang.Object implements ProducerRegistry, TransactionalProducerRegistry
Producer
instances.Constructor and Description |
---|
KafkaProducerFactory(io.micronaut.context.BeanContext beanContext,
SerdeRegistry serdeRegistry,
ProducerFactory producerFactory)
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
close(Producer<?,?> producer)
Closed the producer.
|
<K,V> Producer<K,V> |
getProducer(io.micronaut.inject.InjectionPoint<KafkaProducer<K,V>> injectionPoint,
AbstractKafkaProducerConfiguration<K,V> producerConfiguration)
Creates a new
KafkaProducer for the given configuration. |
<K,V> Producer<K,V> |
getProducer(java.lang.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(java.lang.String id,
java.lang.String transactionalId,
io.micronaut.core.type.Argument<K> keyType,
io.micronaut.core.type.Argument<V> valueType)
Returns a transactional managed Producer.
|
protected void |
stop()
Shuts down any existing clients.
|
public KafkaProducerFactory(io.micronaut.context.BeanContext beanContext, SerdeRegistry serdeRegistry, ProducerFactory producerFactory)
beanContext
- The bean contextserdeRegistry
- The serde registryproducerFactory
- The producer factory@Bean @Any public <K,V> Producer<K,V> getProducer(@Nullable io.micronaut.inject.InjectionPoint<KafkaProducer<K,V>> injectionPoint, @Nullable @Parameter AbstractKafkaProducerConfiguration<K,V> producerConfiguration)
KafkaProducer
for the given configuration.K
- The key typeV
- The value typeinjectionPoint
- The injection point used to create the beanproducerConfiguration
- An optional producer configuration@PreDestroy protected void stop()
public <K,V> Producer<K,V> getProducer(java.lang.String id, io.micronaut.core.type.Argument<K> keyType, io.micronaut.core.type.Argument<V> valueType)
ProducerRegistry
getProducer
in interface ProducerRegistry
K
- The key generic typeV
- The value generic typeid
- The id of the producer.keyType
- The key typevalueType
- The value typepublic <K,V> Producer<K,V> getTransactionalProducer(java.lang.String id, java.lang.String transactionalId, io.micronaut.core.type.Argument<K> keyType, io.micronaut.core.type.Argument<V> valueType)
TransactionalProducerRegistry
getTransactionalProducer
in interface TransactionalProducerRegistry
K
- The key generic typeV
- The value generic typeid
- The client id of the producer.transactionalId
- The transactional id of the producer.keyType
- The key typevalueType
- The value typepublic void close(Producer<?,?> producer)
TransactionalProducerRegistry
ProducerFencedException
is thrown.close
in interface TransactionalProducerRegistry
producer
- The producer