We can specify a timestamp to the kafka ProducerRecord
constructor.
public ProducerRecord(String topic, Integer partition, Long timestamp, K key, V value, Iterable<Header> headers)
What is the intended use of this timesamp? Is it transferred along with the message to the kafka broker?
The record also has an associated timestamp. If the user did not provide a timestamp, the producer will stamp the record with its current time. The timestamp eventually used by Kafka depends on the timestamp type configured for the topic.
CreateTime
, the timestamp in the producer record will be used by the broker.LogAppendTime
, the timestamp in the producer record will be overwritten by the broker with the broker local time when it appends the message to its log.In either of the cases above, the timestamp that has actually been used will be returned to user in RecordMetadata