0
votes

I need to write shell script for reading kafka messages on a particular topic using "bin/kafka-console-consumer.sh --topic quickstart-events --from-beginning --bootstrap-server localhost:9092" only for certain amount of time, say 10 seconds. Using the option --timeout 10s is not helpful, because the process does not stop after 10s if messages are coming continuously on the particular topic. Please suggest how to do the same.

1

1 Answers

0
votes

You can use external script that will kill it after desired time. kafka-console-consumer --timeot-ms flag is for idle time which not what you are looking for.

Alternatively you can stop after --max-messages if you know your message rate/sec and evaluate how many messages you will get in 10s.