Search code examples
spring-bootspring-integrationspring-kafkaspring-cloud-stream

Why are the TIMESTAMP and ID headers from Spring Integration unmapped in Spring Kafka?


Example project with a failing test is at https://github.com/phillipuniverse/kafka-headers-test.

It's odd to me that the ID and TIMESTAMP headers from Spring Integration are being removed in that they cannot be used on the receipt of the message. Is this a bug?

I came across a related issue here that mentioned something about these headers being transient, which makes me think this behavior is intentional. Why are they transient? Why aren't these just like any other custom header which are all mapped in correctly? Is there a particular reason for the special treatment?


Solution

  • This was done for performance reasons where generation of the id and timestamp can impact performance in certain high-volume situations.

    You can change the behavior with the standardHeaders consumer property:

    standardHeaders

    Indicates which standard headers are populated by the inbound channel adapter. Allowed values: none, id, timestamp, or both. Useful if using native deserialization and the first component to receive a message needs an id (such as an aggregator that is configured to use a JDBC message store).

    Default: none