Class CompositeProducerListener<K,V>
java.lang.Object
org.springframework.kafka.support.CompositeProducerListener<K,V>
- Type Parameters:
K- the key type.V- the value type.
- All Implemented Interfaces:
ProducerListener<K,V>
A
ProducerListener that delegates to a collection of listeners.- Since:
- 2.1.6
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDelegate(ProducerListener<K, V> delegate) protected List<ProducerListener<K,V>> voidonError(org.apache.kafka.clients.producer.ProducerRecord<K, V> producerRecord, org.apache.kafka.clients.producer.RecordMetadata recordMetadata, Exception exception) Invoked after an attempt to send a message has failed.voidonSuccess(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).booleanremoveDelegate(ProducerListener<K, V> delegate) final voidsetDelegates(ProducerListener<K, V>... delegates)
-
Constructor Details
-
CompositeProducerListener
-
-
Method Details
-
setDelegates
-
getDelegates
-
addDelegate
-
removeDelegate
-
onSuccess
public void onSuccess(org.apache.kafka.clients.producer.ProducerRecord<K, V> producerRecord, org.apache.kafka.clients.producer.RecordMetadata recordMetadata) Description copied from interface:ProducerListenerInvoked after the successful send of a message (that is, after it has been acknowledged by the broker).- Specified by:
onSuccessin interfaceProducerListener<K,V> - Parameters:
producerRecord- the actual sent recordrecordMetadata- the result of the successful send operation
-
onError
public void onError(org.apache.kafka.clients.producer.ProducerRecord<K, V> producerRecord, org.apache.kafka.clients.producer.RecordMetadata recordMetadata, Exception exception) Description copied from interface:ProducerListenerInvoked after an attempt to send a message has failed.- Specified by:
onErrorin interfaceProducerListener<K,V> - Parameters:
producerRecord- the failed recordrecordMetadata- 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
-