2 回答
TA贡献1818条经验 获得超8个赞
有一个容器属性missingTopicsFatal
: https://docs.spring.io/spring-kafka/api/org/springframework/kafka/listener/ContainerProperties.html#isMissingTopicsFatal - 即使主题和/或经纪人不可用。
@Bean(name = "kafkaListenerContainerFactory")
public ConcurrentKafkaListenerContainerFactory<?, ?> kafkaListenerContainerFactory(
ConsumerFactory<Object, Object> kafkaConsumerFactor,
ConcurrentKafkaListenerContainerFactoryConfigurer configurer) {
ConcurrentKafkaListenerContainerFactory<Object, Object> factory =
new ConcurrentKafkaListenerContainerFactory<>();
configurer.configure(factory, kafkaConsumerFactor);
ContainerProperties containerProperties = factory.getContainerProperties();
containerProperties.setMissingTopicsFatal(false);
...
return factory;
}
TA贡献1848条经验 获得超6个赞
这是新版本的spring的变化。
@Component
class ContainerFactoryConfigurer {
ContainerFactoryConfigurer(ConcurrentKafkaListenerContainerFactory<?, ?> factory) {
factory.getContainerProperties().setMissingTopicsFatal(false);
}
}
添加回答
举报