0

When a Spring Kafka MessageListener is consuming messages from multiple partitions, it keeps processing messages from one partition until there are no more messages and only after that it continues with the next partition. (based on my observations)

Is it possible to set a max number of messages/batches and tell the Listener to switch faster to the next partition rather than later?

This would improve fairness and consume evenly from all assigned partitions.

Viorel Vesa
  • 300
  • 1
  • 2
  • 12
  • Does this answer your question? [How do messages get consumed in Kafka when there are more partitions than consumers?](https://stackoverflow.com/questions/35701899/how-do-messages-get-consumed-in-kafka-when-there-are-more-partitions-than-consum) – Chin Huang Feb 11 '22 at 17:53

1 Answers1

1

switch faster to the next partition, consume evenly from all assigned partitions

I don't think Kafka has any properties for this. kafka consumer config

It's weird. You could see a partition replica in Kafka as a log file. Your consumer poll runs in one thread, for better performance, it should consume from one file, and the next poll will consume from another file rather than separate it and consume evenly from many partitions for each poll, right? Eventually, you still need to consume all of the messages on the topic.

Linh Vu
  • 736
  • 3
  • 7