Package io.apicurio.registry.utils.kafka
Class AsyncProducer<K,V>
- java.lang.Object
-
- io.apicurio.registry.utils.kafka.AsyncProducer<K,V>
-
- All Implemented Interfaces:
ProducerActions<K,V>
,AutoCloseable
,Function<org.apache.kafka.clients.producer.ProducerRecord<K,V>,CompletableFuture<org.apache.kafka.clients.producer.RecordMetadata>>
public class AsyncProducer<K,V> extends Object implements ProducerActions<K,V>
An async wrapper for kafka producer that is resilient in the event of failures - it recreates the underlying kafka producer when unrecoverable error occurs. This producer is not suitable for transactional use. It is suitable for normal or idempotent use.
-
-
Constructor Summary
Constructors Constructor Description AsyncProducer(Properties producerProps, org.apache.kafka.common.serialization.Serializer<K> keySerializer, org.apache.kafka.common.serialization.Serializer<V> valSerializer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CompletableFuture<org.apache.kafka.clients.producer.RecordMetadata>
apply(org.apache.kafka.clients.producer.ProducerRecord<K,V> record)
void
close()
-
-
-
Constructor Detail
-
AsyncProducer
public AsyncProducer(Properties producerProps, org.apache.kafka.common.serialization.Serializer<K> keySerializer, org.apache.kafka.common.serialization.Serializer<V> valSerializer)
-
-
Method Detail
-
apply
public CompletableFuture<org.apache.kafka.clients.producer.RecordMetadata> apply(org.apache.kafka.clients.producer.ProducerRecord<K,V> record)
-
close
public void close()
- Specified by:
close
in interfaceAutoCloseable
-
-