Reputation: 671
I am creating a service which talks to another service in order to identify kafka topics to be listened to. The kafka topics may have different key and value types. Hence, I want to dynamically create different kafka consumers for each configuration(topic, key type, value type) where the configurations are known only at runtime. However in spring kafka, I don't see ways to pass all these parameters dynamically(at least I am not aware of any). How should I go ahead with this.
Upvotes: 2
Views: 15947
Reputation: 174759
Simply create a new listener container at runtime.
If you are using Spring Boot, you can use the ConcurrentKafkaListenerContainerFactory
that it automatically configures, to create containers; if not, just create and initialize the containers manually.
Upvotes: 4