When I am sending a message to my Kafka listener, I am sending custom headers along with the message. I was following this https://memorynotfound.com/spring-kafka-adding-custom-header-kafka-message-example/
But since I have a batch listener this doesn't work. I have heard of KafkaHeaderMapper
but I don't know how to implement it.
Can someone please show me with code how can I produce with my custom header and capture it on the listener side?
I am using SpringBoot
with SpringKafka
EDIT 1
In my List messages, this is the data, My header is being added to the message itself. Why is this happening?
{
"payload":"\"test\"",
"headers":{
"X-Custom-Header":"Sending Custom Header with Spring Kafka",
"id":"18280539-fcd2-e08a-6b01-e80df430858a",
"timestamp":1619500941341
}
}