Apache Kafka stores the message with offset. The following are several ways the messages can be retrieved with time;
Message Creation
When When the message is created append the runtime to the message in the producer class before publishing the message to the topic as follows:
...
producer.send(data);
The message can be retrieved using the runtime timestamp.
Apache Kafka System Tools
Apache Apache Kafka provided following system tools:
...
Kafka Low Level Consumer API
For message partition reading, the kafka.api.OffsetRequest
class defines two constants: EarliestTime
and LatestTime
,
to find the beginning of the data in the logs and the new messages stream.