From a couple of days I'm trying out ways to dynamically pass topics to Kafka listener rather than using them through keys from a Java DSL. Anyone around done this before or could throw some light on what is the best way to achieve this?
The easiest solution I found was to use SpEL:
@Autowired
private SomeBean kafkaTopicNameProvider;
@KafkaListener(topics = "#{kafkaTopicNameProvider.provideName()}")
public void listener() { ... }
You cannot "dynamically pass topics to Kafka listener "; you have to programmatically create a listener container instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With