@Factory public class KafkaProducerFactory extends java.lang.Object implements ProducerRegistry
Producer instances.| Constructor and Description |
|---|
KafkaProducerFactory(io.micronaut.context.BeanContext beanContext,
SerdeRegistry serdeRegistry)
Default constructor.
|
| Modifier and Type | Method and Description |
|---|---|
<K,V> org.apache.kafka.clients.producer.Producer<K,V> |
getProducer(io.micronaut.inject.InjectionPoint<org.apache.kafka.clients.producer.KafkaProducer<K,V>> injectionPoint,
AbstractKafkaProducerConfiguration<K,V> producerConfiguration)
Creates a new
KafkaProducer for the given configuration. |
<K,V> org.apache.kafka.clients.producer.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.
|
protected void |
stop()
Shuts down any existing clients.
|
public KafkaProducerFactory(io.micronaut.context.BeanContext beanContext,
SerdeRegistry serdeRegistry)
beanContext - The bean contextserdeRegistry - The serde registry@Bean
@Any
public <K,V> org.apache.kafka.clients.producer.Producer<K,V> getProducer(@Nullable
io.micronaut.inject.InjectionPoint<org.apache.kafka.clients.producer.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> org.apache.kafka.clients.producer.Producer<K,V> getProducer(java.lang.String id,
io.micronaut.core.type.Argument<K> keyType,
io.micronaut.core.type.Argument<V> valueType)
ProducerRegistrygetProducer in interface ProducerRegistryK - The key generic typeV - The value generic typeid - The id of the producer.keyType - The key typevalueType - The value type