Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kafka: How to get last modified time for a topic i.e. last message added to any partition of the topic

Our use case is to delete stale/unused topics from kafka i.e. if a topic (on all partitions) doesn't have any new message in last 7 days then we would consider it as stale/unused and delete it.

Many google results suggested to add timestamp to messages and then parse it. For new topics & messages that soultion would work but our existing topics & messages doesn't have any timestamp in them.

How can I get this working ?.

like image 578
inari6 Avatar asked Jul 30 '15 23:07

inari6


1 Answers

kafka.api.OffsetRequest.LatestTime() will return the latest message added to a queue. You can use the Simple Consumer API to determine which offset to read from.

For more details take look at the wiki page

like image 96
user2720864 Avatar answered Sep 22 '22 17:09

user2720864