Description
I'm using Spring Kafka 3.1.2
Apache Kafka allows to have multiple headers with same key, but Spring Kafka limits that.
Sample project reproducting the issue is available here:
https://github.com/poznachowski/sample-spring-kafka-headers
When I use Listener with ConsumerRecord
directly as payload I can see all the headers:
ConsumerRecord payload: SomePayload[value=payload], headers: RecordHeaders(headers = [RecordHeader(key = testHeader, value = [118, 97, 108, 117, 101, 49]), RecordHeader(key = testHeader, value = [118, 97, 108, 117, 101, 50])], isReadOnly = false)
But I'd like to use much more convenient Spring abstractions such as: @Payload
and @Headers
, but with this approach I'm getting only a single testHeader
value:
headers: {kafka_offset=11, testHeader=[B@67388d79, ...
The reason for that is that KafkaHeaderMapper
implementations uses Map.put
method that effective replaces value with the latest.