Program for Kafka Producer and Consumer and count the number of messages sent to topic

I want to write a program, in which there is dummy Kafka Producer and Consumer. Producer is sending a stream of messages on a topic and consumer is consuming them continuously.
There is another separate program (bash, java or anything) which will tell how many total messages have been sent to the topic and how many have been consumed or committed by the consumer at that time.