Interface ProducerListener<K,​V>

  • Type Parameters:
    K - the key type.
    V - the value type.
    All Known Implementing Classes:
    CompositeProducerListener, LoggingProducerListener

    public interface ProducerListener<K,​V>
    Listener for handling outbound Kafka messages. Exactly one of its methods will be invoked, depending on whether the write has been acknowledged or not. Its main goal is to provide a stateless singleton delegate for Callbacks, which, in all but the most trivial cases, requires creating a separate instance per message.
    Author:
    Marius Bogoevici, Gary Russell, Endika GutiƩrrez
    See Also:
    Callback
    • Method Summary

      All Methods Instance Methods Default Methods 
      Modifier and Type Method Description
      default void onError​(org.apache.kafka.clients.producer.ProducerRecord<K,​V> producerRecord, java.lang.Exception exception)
      Invoked after an attempt to send a message has failed.
      default void onSuccess​(org.apache.kafka.clients.producer.ProducerRecord<K,​V> producerRecord, org.apache.kafka.clients.producer.RecordMetadata recordMetadata)
      Invoked after the successful send of a message (that is, after it has been acknowledged by the broker).
    • Method Detail

      • onSuccess

        default void onSuccess​(org.apache.kafka.clients.producer.ProducerRecord<K,​V> producerRecord,
                               org.apache.kafka.clients.producer.RecordMetadata recordMetadata)
        Invoked after the successful send of a message (that is, after it has been acknowledged by the broker).
        Parameters:
        producerRecord - the actual sent record
        recordMetadata - the result of the successful send operation
      • onError

        default void onError​(org.apache.kafka.clients.producer.ProducerRecord<K,​V> producerRecord,
                             java.lang.Exception exception)
        Invoked after an attempt to send a message has failed.
        Parameters:
        producerRecord - the failed record
        exception - the exception thrown