Class 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 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)
        Specified by:
        apply in interface Function<K,​V>