I want to track records timestamps in kafka producer: when record was sent by producer and when broker receive acks and store record (on ack timestamp). Each record has string id in headers.
For me the best way for it is implement Kafka ProducerInterceptor:
@Override
public ProducerRecord<K, V> onSend(ProducerRecord<K, V> record) {
}
@Override
public void onAcknowledgement(RecordMetadata metadata, Exception exception) {
}
In onAcknowledgement i have RecordMetadata and can get acks timestamp, but i can't understand how i can match for which record i receive metadata?
As I can see from KIP-512 it's common problem, and under discussion.
How I can match record in onAcknowledgement? Or may be there is a better way to track record's send/receive timestamps?
And no, I can't use Producer callback, cause i can't change producer code.