We can get every messages from Kafka by doing:
bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic test --from-beginning
Is there a way to get only the last message ?
EDIT:
If you just want to monitor some messsages (--max-messages 10
) in your stream, a convenient command is :
watch -n5 "./bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic auction --max-messages 10"
bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic test --from-beginning --timeout-ms 10 | tail -n 1
(The timeout-ms kills the consumer after its read everything)