1

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.
OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
VKR
  • 195
  • 4
  • 18

1 Answers1

1

Remove the spaces

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

Or use

.split(' *, *')
Gary Russell
  • 166,535
  • 14
  • 146
  • 179