Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find first message which is not deleted in Kafka topic

I have a topic and there are some messages in it. A part of messages was deleted after retention time was out including a message on which offset points and many messages after it.

How to find the oldest existing message in the topic? I heard there is some method in API but I can't find it. If someone knows how to do it, please help, 'cause I'm already tortured by searching it in the documentation. Thanks in advance.

like image 742
Dmitry Goryaynov Avatar asked Dec 14 '25 17:12

Dmitry Goryaynov


1 Answers

You can use kafka-console-consumer with --max-messages 1 and --from-beginning in order to fetch the oldest message:

kafka-console-consumer --bootstrap-server localhost:9092 --topic topic_name --from-beginning --max-messages 1
like image 131
Giorgos Myrianthous Avatar answered Dec 17 '25 08:12

Giorgos Myrianthous



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!