I’m creating java microservice application on Spring Cloud + Kafka, and during the process of development I asked myself a question if I’m creating kafka topics correctly. I was doing this like this:
@Bean
public NewTopic employee() {
return new NewTopic("email", 5, (short) 1);
}
So the problem is that in every microservice project I am creating different topics, I dont have a centralized place for this, is it a good practice? I was thinking about creating a special microservice for creating kafka topics only, but I’m not sure about this, because I don’t think that this microservice will have any use other then creating topics in @Configuration class. So my question is: which is the right place for creating topics? Is it good to create them like in the above example or maybe I should create them other way? Shoul the place of creation be centralized (like special microservice) or it’s better to create topics in different microservices due to the domain requirements?