Reputation: 339
I want to read from multiple topics, so i declared them in yaml file with comma separated but getting below error:
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
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.
Upvotes: 1
Views: 1430
Reputation: 174544
Remove the spaces
tp: topic-1,topic-2,topic-3,topic-4,topic-5,topic-6,topic-7
Or use
.split(' *, *')
Upvotes: 1