0

I am using spring-cloud-stream, version - 2022.0.0 along with spring boot version3.0.1, to publish a Cloud Event message to a kafka topic. I am using CloudEventMessageBuilderto build a message and headers, and usingStreamBridge` to send it to topic.

    Message<String> message = CloudEventMessageBuilder.withData(payload)
            .setType("CustomType")
            .setSource("CustomSource")
            .setSubject("CustomSubject")
            .build();

    streamBridge.send("channel-out-0", message);

Though I am able to publish the message on kafka topic, the headers I have set has been removed or overridden by StreamBridge.

Here is the behaviour I am seeing -

Header Set Value Value Sent to Kafka
ce_type CustomType java.lang.String
ce_source CustomSource http://spring.io/
ce_subject CustomSubject (Absent)

Sample Code https://github.com/moazzamkhan/stream-bridge-test

How can i set headers?

Thanks

Moazzam Khan
  • 3,130
  • 2
  • 20
  • 35

1 Answers1

1

Thank you for reporting it. It's a bug, so I just filed it. Will be fixed by 4.0.1 and released in few weeks - https://github.com/spring-cloud/spring-cloud-function/issues/985

Oleg Zhurakousky
  • 5,820
  • 16
  • 17
  • The issue is fixed and will be available in the next release. Here is the test case - https://github.com/spring-cloud/spring-cloud-stream/commit/9fe6db2e56e3bf0302e34aab4f110b204d4d718f (partially copied from yours) – Oleg Zhurakousky Jan 11 '23 at 15:47