You can use SimpleConsumer.getOffsetsBefore to get a list of offsets before a Unix timestamp. However, this isn't per-message. The offests returned are for the log segments stored on the broker, so the granularity will depend on your log rolling settings.
-Ewen On Wed, Aug 5, 2015 at 2:11 AM, shahab <[email protected]> wrote: > Hi, > > Probably this question has been already asked before, but I couldn't find > it, > > I would like to fetch data from kafka by timestamp, and according to Kafk > FAQ ( > > https://cwiki.apache.org/confluence/display/KAFKA/FAQ#FAQ-HowdoIaccuratelygetoffsetsofmessagesforacertaintimestampusingOffsetRequest > ?) > "Kafka allows querying offsets of messages by time", I tried to use > UnixTimeStamp instead in the offset request, but every time I got an empty > array, simply it didn't work. > > Based on my google search this is not possible, but Kafka FAQ states that > this is possible! > Does any one know how to do this? I do appreciate it. > > best, > /Shahab > -- Thanks, Ewen
