How to add error handler for producer when using spring Kafka? I know how to add error handler for consumer but I am not sure about producer.
See KafkaTemplate:
/**
* Set a {@link ProducerListener} which will be invoked when Kafka acknowledges
* a send operation. By default a {@link LoggingProducerListener} is configured
* which logs errors only.
* @param producerListener the listener; may be {@code null}.
*/
public void setProducerListener(ProducerListener<K, V> producerListener) {
this.producerListener = producerListener;
}
And that one has this:
/**
* Invoked after an attempt to send a message has failed.
* @param topic the destination topic
* @param partition the destination partition (could be null)
* @param key the key of the outbound message
* @param value the payload of the outbound message
* @param exception the exception thrown
*/
void onError(String topic, Integer partition, K key, V value, Exception exception);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With