cloudevents / cloudevents/sdk-java
Spring CloudEventMessageConverter content-type header name
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 446
- Forks
- 172
- PR merge metrics
- No merged PRs in 30d
Description
Spring CloudEventMessageConverter content-type header name uses the Spring Messaging contentType header name which differs fom the cloud events spec content-type which is used by Kafka serializer for instance.
This leads to a message from a project using structured mode and kafka serializer (sdk-kafka) to not be deserialized by another project using (sdk-spring).
The current code is as follows on sdk-spring:
if (message.containsKey(MessageHeaders.CONTENT_TYPE)) {
return String.valueOf(message.get(MessageHeaders.CONTENT_TYPE));
}
if (message.containsKey(CloudEventsHeaders.CONTENT_TYPE)) {
return String.valueOf(message.get(CloudEventsHeaders.CONTENT_TYPE));
}
Unfortunately the CloudEventsHeaders.CONTENT_TYPE is CE_PREFIX + "datacontenttype" which is not exactly the same property we are looking here.
I would be happy to create a merge request where a another fallback is introduced to have the spec header name (content-type) which would enable the sdk-spring to deserialize messages.
This would add the support while still keeping it compatible with different versions and services.
Ideally, also the spring-sdk serializer should be checked and changed, but i would rather have this small mr fixed and dive on the serializer in a different issue.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Locate the Spring CloudEventMessageConverter code in sdk-spring and inspect how it reads content-type headers. Verify the serializer and deserializer interaction described in the issue, then preserve the existing fallbacks while supporting the CloudEvents spec header name; done means structured messages from sdk-kafka deserialize through sdk-spring.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, kafka, spring
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100