当Kafka broker变得不可用时,我的spring boot 2.1.5消费者应用程序宕机,异常如下。它使用的是spring-kafka 2.2.6。我需要我的应用程序保持运行,并在kafka broker回来后继续消费。
例外:
org.springframework.context.ApplicationContextException: Failed to start bean
'org.springframework.kafka.config.internalKafkaListenerEndpointRegistry';
nested exception is org.apache.kafka.common.errors.TimeoutException: Timeout expired while fetching topic metadata我已经尝试了@KafkaListener和autostartup=false,并使用CommandLineRunner解决了这个问题,该应用程序不会宕机,但当broker返回时,它不会使用消息,直到重新启动。
发布于 2019-12-12 05:29:36
将容器属性misssingTopicsFatal设置为false,以防止在初始化期间尝试连接到代理。它现在默认情况下是false (在2.3.4版和更高版本中)。
您可以使用KafkaListenerEndpointRegistry bean启动autoStartup=false容器--为侦听器提供一个id,并使用它从注册表中获取对容器的引用。
https://stackoverflow.com/questions/59293756
复制相似问题