I am working on a spring boot kafka consumer application. It will have different consumers working on different topics. All the information for the consumers will come from the application.yml file.
application:
kafka:
consumer-config:
- name: consumer-a
topics: topic1,topic2
......
- name: consumer-b
topics: topic3,topic4
.....
I am not able to set the list of topics from the application properties on to the KafkaListener.
I tried the following:
@KafkaListener(topics = "#{'${application.kafka.consumer-config[0].topics}'.split(',')}",containerFactory = "kafkaListenerContainerFactory")
@KafkaListener(topics = "#{'${application.kafka.consumer-config.?[name == 'consumer-a'].topics}'.split(',')}", containerFactory = "kafkaListenerContainerFactory")
In both the cases I am getting the following error:
java.lang.IllegalArgumentException: Could not resolve placeholder
What is the best way to get the topics from application properties and set it on KafkaListener topics?