'How to measure messages processed by Kafka Consumer Group in a given time?[Java]

I am consuming from a topic having 5 partitions and I need to measure how many messages can a consumer group having 5 consumers can process in a minute. If I try to manually switch on all the consumers at a time, some of the messages gets consumed while rebalancing the group.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source