Class CompositeProducerListener<K,​V>

  • Type Parameters:
    K - the key type.
    V - the value type.
    All Implemented Interfaces:
    ProducerListener<K,​V>

    public class CompositeProducerListener<K,​V>
    extends java.lang.Object
    implements ProducerListener<K,​V>
    A ProducerListener that delegates to a collection of listeners.
    Since:
    2.1.6
    Author:
    Gary Russell, Artem Bilan
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      void addDelegate​(ProducerListener<K,​V> delegate)  
      protected java.util.List<ProducerListener<K,​V>> getDelegates()  
      void onError​(org.apache.kafka.clients.producer.ProducerRecord<K,​V> producerRecord, java.lang.Exception exception)
      Deprecated.
      void onError​(org.apache.kafka.clients.producer.ProducerRecord<K,​V> producerRecord, org.apache.kafka.clients.producer.RecordMetadata recordMetadata, java.lang.Exception exception)
      Invoked after an attempt to send a message has failed.
      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).
      boolean removeDelegate​(ProducerListener<K,​V> delegate)  
      void setDelegates​(ProducerListener<K,​V>... delegates)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CompositeProducerListener

        @SafeVarargs
        public CompositeProducerListener​(ProducerListener<K,​V>... delegates)
    • Method Detail

      • setDelegates

        @SafeVarargs
        public final void setDelegates​(ProducerListener<K,​V>... delegates)
      • onSuccess

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

        @Deprecated
        public void onError​(org.apache.kafka.clients.producer.ProducerRecord<K,​V> producerRecord,
                            java.lang.Exception exception)
        Deprecated.
        Description copied from interface: ProducerListener
        Invoked after an attempt to send a message has failed.
        Specified by:
        onError in interface ProducerListener<K,​V>
        Parameters:
        producerRecord - the failed record
        exception - the exception thrown
      • onError

        public void onError​(org.apache.kafka.clients.producer.ProducerRecord<K,​V> producerRecord,
                            org.apache.kafka.clients.producer.RecordMetadata recordMetadata,
                            java.lang.Exception exception)
        Description copied from interface: ProducerListener
        Invoked after an attempt to send a message has failed.
        Specified by:
        onError in interface ProducerListener<K,​V>
        Parameters:
        producerRecord - the failed record
        recordMetadata - The metadata for the record that was sent (i.e. the partition and offset). If an error occurred, metadata will contain only valid topic and maybe the partition. If the partition is not provided in the ProducerRecord and an error occurs before partition is assigned, then the partition will be set to RecordMetadata.UNKNOWN_PARTITION.
        exception - the exception thrown