Closed PaulV1990 closed 2 years ago
@PaulV1990 This was a bug. It is now addressed in main
(4.0.0-SNAPSHOT
) through the commit mentioned above. I will update here when the 3.2.5-SNAPSHOT
is ready for you to try. Thanks!
@PaulV1990 Both 3.2.5-SNAPSHOT
and 4.0.0-SNAPSHOT
have the fix now.
Describe the issue
I produce a Message (org.springframework.messaging) in application X. I've implemented a custom MessageConverter that implements SmartMessageConverter. The message is sent to a topic with custom headers and with a CLI consumer the custom headers are available.
When using a Kstream in Java application Y, the custom headers are not available.
I use the configuration:
With this, i only receive these three (default) headers in the log:
I verified that the custom MessageConvertor is called, but fails because the custom headers are missing.
When using a different consumer like:
I can see all the headers (custom and kafka ):
I have also tried setting the
spring.cloud.stream.bindings.streamuser-in-0.consumer.header-mode
but this didn't fix it.To Reproduce Steps to reproduce the behavior:
The message conversion is used to encrypt the byte[] after serialisation and decrypt the byte[] before deserialisation. A simplified example of the SmartMessageConverter.
Sending the Message is done with a custom KafkaTemplate with the CustomMessageConverter set and adapted the method:
When debugging, it seems that in the class:
The headers from the Record are unused when the GenericMessage (newValue) is created. Only record.key and record.value are processed.
Version of the framework org.springframework.cloud:spring-cloud-stream-binder-kafka-streams:3.2.3
Expected behavior When converting the Record to GenericMessage all (custom) headers are copied instead of ignored/lost.
Screenshots
Additional context Original question on StackOverflow, redirected to here by Soby Chacko