-
Notifications
You must be signed in to change notification settings - Fork 159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Does CloudEventDeserializer deserialize custom extensions (kafka headers)? #587
Comments
Hi @alfonz19, thanks for reporting, in Kafka, when sending the event, you should see a header This is done by serializer in sdk-java/kafka/src/main/java/io/cloudevents/kafka/impl/BaseKafkaMessageWriterImpl.java Lines 41 to 48 in a135755
sdk-java/kafka/src/main/java/io/cloudevents/kafka/CloudEventSerializer.java Lines 93 to 95 in a135755
|
how are you writing records to Kafka? Can you share a small reproducer? |
Sorry for delay, I had to verify it. Thanks again for your help! |
I have cloudevent instance build using
io.cloudevents.core.v1.CloudEventBuilder builder
and I gave it custom extension using methodbuilder.withExtension("whatever", "whatever");
. Cloudevent is built, sent. I can see, that in kafka, there is respective message, and it has header "whatever" having value "whatever". So far so good.But if I deserialize given message into
io.cloudevents.CloudEvent
instance, the header isn't 'there'. I'd expect it inio.cloudevents.CloudEventExtensions#getExtensionNames
resp.io.cloudevents.CloudEventExtensions#getExtension
but it's not there or anywhere else.Looking into
io.cloudevents.kafka.CloudEventDeserializer
we can dig deep and reachio.cloudevents.core.message.impl.BaseGenericBinaryMessageReaderImpl#read
, which is shown below.Debugging this method, we will find here our header, key==value=="whatever". So value is not null, we continue, it's not "content-type" header so we proceed to else branch, and it does not have "ce_" prefix (isCloudEventsHeader), and we're done. Custom extension ignored.
This is expected to happen? Am I overlooking smth? I'd expect, that if I am able to create Cloudevent with custom extension, I'd like to read it as well. Is there some special configuration for that or anything I forgot to enable?
(also posted here: https://stackoverflow.com/questions/77099281/does-cloudeventdeserializer-deserialize-custom-extensions-kafka-headers)
The text was updated successfully, but these errors were encountered: