KafkaHeaders defines constants for accessing Kafka record metadata in Spring Kafka. Consumer-side constants begin with RECEIVED, distinguishing incoming-record headers from producer metadata. section 12.2.2
Read incoming record metadata
Annotate listener parameters with KafkaHeaders constants to retrieve the incoming timestamp and message key; topic, partition, and offset are also available. section 12.2.2
Listing 12.13 Getting the message key and timestamp from the incoming Kafka record
public void doProcessLoanApplication(LoanApplication loanApplication,
@Header(Kafka Headers.RECEIVED_TIMESTAMP)
long timestamp, #1
@Header(Kafka Headers.RECEIVED_MESSAGE_KEY)
String key) #2
See the listener signature using RECEIVED_TIMESTAMP and RECEIVED_MESSAGE_KEY to extract metadata alongside the loan application. section 12.2.2
