I am using the spring cloud stream event binder for Azure event hubs and follow the setup in this tutorial. Now I want to set a custom value to the id Header of the message produced.
I know that those headers are read only in the Spring Message interface
So if I do something like this
MessageBuilder.withPayload(myPayload)
.setHeader("id", "myCustomIdHeaderValue")
.build(),
I get
java.lang.IllegalArgumentException: 'id' header is read-only
I want to integrate with an existing system which requires the messages header id to hold specific values and specified by the producer - unfortunately I cannot use another custom header for this one. As a fallback I could use the plain azure event hub SDK but would prefer using Spring Cloud Stream binder instead if possible. The restrictions are there for valid reasons and overriding them doesn't sound like a good idea, but is there a way to overcome this anyway ?