[英]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.