OiO.lk Blog java timestamp header value getting replaced at consumer
java

timestamp header value getting replaced at consumer


I have a kafka producer sending data using KafkaTemplate.send(). In the ProducerRecord, I add a header with key ‘timestamp’ and add a custom timestamp value. I have a consumer consuming records using @KafkaListener to ConsumerRecord object. When I try to access the ‘timestamp’ header from this consumer record, I get the value whatever I send from producer. Now I have one more consumer written using Consumer<Message> as a bean. Here the kafka configurations are done using kafka binding(spring.cloud.stream.kafka). When I extract the ‘timestamp’ header from the received Message object, the value is different than I send from producer. How can I fix this? Is there any way I can reuse the original ‘timestamp’ key and keep the custom timestamp value?



You need to sign in to view this answers

Exit mobile version