Class AsyncKafkaExporter<T>

java.lang.Object
io.confluent.telemetry.events.exporter.kafka.async.AsyncKafkaExporter<T>
Type Parameters:
T -
All Implemented Interfaces:
Exporter<T>, AutoCloseable, org.apache.kafka.common.Configurable, org.apache.kafka.common.Reconfigurable
Direct Known Subclasses:
EventAsyncKafkaExporter

public class AsyncKafkaExporter<T> extends Object implements Exporter<T>
This KafkaExporter does not block the calling thread. It adds the data to a queue and returns immediately. A consumer thread drains the queue and sends the data to Kafka.

The exporter emit method returns a CompletableFuture object with a boolean that indicates if event has been sent or dropped, caller can either wait on the result and decide what to do based on result, or ignore the result.

  • Method Details

    • newBuilder

      public static <T> AsyncKafkaExporter.Builder<T> newBuilder()
    • reconfigurableConfigs

      public Set<String> reconfigurableConfigs()
      Specified by:
      reconfigurableConfigs in interface org.apache.kafka.common.Reconfigurable
    • validateReconfiguration

      public void validateReconfiguration(Map<String,?> configs) throws org.apache.kafka.common.config.ConfigException
      Specified by:
      validateReconfiguration in interface org.apache.kafka.common.Reconfigurable
      Throws:
      org.apache.kafka.common.config.ConfigException
    • reconfigure

      public void reconfigure(Map<String,?> configs)
      Specified by:
      reconfigure in interface org.apache.kafka.common.Reconfigurable
    • configure

      public void configure(Map<String,?> configs)
      Specified by:
      configure in interface org.apache.kafka.common.Configurable
    • emit

      public CompletableFuture<Boolean> emit(T t)
      Description copied from interface: Exporter
      Filter and transform the events as appropriate and send to the specified destination. This method takes care of batching, serialization and retries.
      Specified by:
      emit in interface Exporter<T>
      Returns:
      A CompletableFuture object with a Boolean value, indicates if event has been sent successfully
    • buffer

      public BlockingDeque<io.confluent.telemetry.events.exporter.kafka.async.AsyncKafkaExporter.Tuple<T>> buffer()
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
    • producer

      public Object producer()
      Returns the producer if it has been created, null otherwise. With lazy initialization, the producer may not exist until the first emit.
    • isProducerCreated

      public boolean isProducerCreated()
      Returns true if the producer has been created.