[英]KafkaListener mulitple topics in yaml file
I want to read from multiple topics, so i declared them in yaml file with comma separated but getting below error:我想阅读多个主题,所以我在 yaml 文件中声明了它们,用逗号分隔但出现以下错误:
java.lang.IllegalStateException: Topic(s) [ topic-1, topic-2, topic-3, topic-4, topic-5, topic-6, topic-7] is/are not present and missingTopicsFatal is true java.lang.IllegalStateException: 主题 [topic-1, topic-2, topic-3, topic-4, topic-5, topic-6, topic-7] 是/不存在且 missingTopicsFatal 为真
Spring:
kafka:
topics:
tp: topic-1 , topic-2, topic-3, topic-4, topic-5, topic-6, topic-7
@KafkaListener(topics = "#{'${spring.kafka.topics.tp}'.split(',')}",
concurrency = "190",
clientIdPrefix = "client1",
groupId = "group1")
public void listenData(final ConsumerRecord<Object, Object> inputEvent) throws Exception {
handleMessage(inputEvent);
}
if i declare all topics inside KafkaListener annotation its working fine.
Remove the spaces删除空格
tp: topic-1,topic-2,topic-3,topic-4,topic-5,topic-6,topic-7
Or use或使用
.split(' *, *')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.