繁体   English   中英

yaml 文件中的 KafkaListener 多个主题

[英]KafkaListener mulitple topics in yaml file

我想阅读多个主题,所以我在 yaml 文件中声明了它们,用逗号分隔但出现以下错误:

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.

删除空格

tp: topic-1,topic-2,topic-3,topic-4,topic-5,topic-6,topic-7

或使用

.split(' *, *')

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM