gpt4 book ai didi

spring-kafka - 使用spring Kafka时如何为生产者添加错误处理程序

转载 作者:行者123 更新时间:2023-12-04 14:25:00 25 4
gpt4 key购买 nike

使用spring Kafka时如何为producer添加error handler?我知道如何为消费者添加错误处理程序,但我不确定生产者。

最佳答案

参见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;
}

那个有这个:

/**
* 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);

关于spring-kafka - 使用spring Kafka时如何为生产者添加错误处理程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47818415/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com