I configure 10 kafka topics in my yaml file and I need create all topics on aplication start. But I do not understand how can I do it with List. I can Create one bean:
@Bean
public NewTopic newTopic() {
return new NewTopic("topic-name", 5, (short) 1);
}
But now I have list configs:
@PostConstruct
public void init(){
Map<String, TopicProperties.Topic> topics = this.topics.getTopics();
for (Map.Entry<String, TopicProperties.Topic> topicEntry : topics.entrySet()) {
TopicProperties.Topic topic = topicEntry.getValue();
String topicName = topic.getTopicName();
int partitions = topic.getNumPartitions();
short replicationFactor = topic.getReplicationFactor();
//how can I create new bean of NewTopic?
}
}