【问题标题】:How to disable container stop when kafka error spring kafka当kafka错误spring kafka时如何禁用容器停止
【发布时间】:2021-12-24 04:35:10
【问题描述】:
当我的 kafka 代理出现身份验证错误时,应用程序会丢弃容器。
有没有办法禁用这种行为?
我正在使用 KafkaListener
@KafkaListener(topics = "${spring.kafka.consumer.topic}", concurrency = "${listen.concurrency:3}")
public void topicListener(Product<String> message) {
getLogger().info("message consumed");
}
如果我需要发布其他设置,请告诉我..
【问题讨论】:
标签:
spring
spring-boot
apache-kafka
spring-kafka
【解决方案1】:
请参阅ConsumerProperties 上的authorizationExceptionRetryInterval 选项:
/**
* Set the interval between retries after {@code AuthorizationException} is thrown
* by {@code KafkaConsumer}. By default the field is null and retries are disabled.
* In such case the container will be stopped.
*
* The interval must be less than {@code max.poll.interval.ms} consumer property.
*
* @param authorizationExceptionRetryInterval the duration between retries
* @since 2.3.5
*/
public void setAuthorizationExceptionRetryInterval(Duration authorizationExceptionRetryInterval) {
有关更多信息,请参阅文档:https://docs.spring.io/spring-kafka/docs/current/reference/html/#kafka-container
默认情况下,没有配置时间间隔 - 授权错误被认为是致命的,这会导致容器停止。