'Create consumer dynamically spring kafka
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.
Solution 1:[1]
Simply create a new listener container at runtime.
https://docs.spring.io/spring-kafka/docs/current/reference/html/#message-listener-container
If you are using Spring Boot, you can use the ConcurrentKafkaListenerContainerFactory that it automatically configures; if not, just create and initialize the containers manually.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Gary Russell |
