I want to create a concurrent @KafkaListener
which can handle multiple topics each with different number of partitions.
I have noticed that Spring-Kafka only initializes one consumer per partition for the topic with most partitions.
Example: I have set concurrency to 8. I got a @KafkaListener
listening to the following topics. Topic A has the most partitions - 5, so Spring-Kafka initializes 5 consumers. I expected Spring-Kafka to initialize 8 consumers, which is the maximum allowed according to my concurrency property.
- Topic A has 5 partitions
- Topic B has 3 partitions
- Topic C has 1
What is the technical reason for not initializing more consumers?
How do I bypass this, such that I can initialize more consumers using the @KafkaListener
annotation? (if possible at all)