Hi! I recently tried to use this extension when subscribing to a topic that wraps XML data in a CloudEvent envelope. I control both the publisher and subscriber, so I set the datacontenttype field of the CloudEvent envelope to application/xml and set the XML data as as string in the data field. This in line with an example Dapr has in their documentation, although they set the datacontenttype to text/xml: https://docs.dapr.io/developing-applications/building-blocks/pubsub/pubsub-cloudevents/#dapr-generated-cloudevents-example
In my subscriber I defined an endpoint with a signature like this:
@POST
@Consumes("application/cloudevents+json")
@Topic(name = "my-topic", pubsubName = "pubsub")
fun processMessage(headers: HttpHeaders, event: CloudEvent<String>): Response {
When I tested the endpoint with curl I was confused to receive a 415 error, eventhough the Content-Type header of my request was set to application/cloudevents+json. I did some digging and found the reason to be io.quarkiverse.dapr.resteasy.CloudEventReader´, specifically getCloudEventthat reads thedatacontenttype. This method only accepts application/json, text/plain, and application/octet-stream`.
To work around my issue, I tried setting the datacontenttype to text/plain, but was unsuccessful. I then got ParseException. I think this is because my data is not valid JSON and ObjectMapper#readValue is called with a simple type of CloudEvent<String>, and not String?
In the end, I can work around this issue by base64 encoding my XML and setting it in data_base64 instead, but it adds overhead to the transfer. I also think it would be useful for this extension to support more than the three aforementioned media types.
Hi! I recently tried to use this extension when subscribing to a topic that wraps XML data in a CloudEvent envelope. I control both the publisher and subscriber, so I set the
datacontenttypefield of the CloudEvent envelope toapplication/xmland set the XML data as as string in thedatafield. This in line with an example Dapr has in their documentation, although they set thedatacontenttypetotext/xml: https://docs.dapr.io/developing-applications/building-blocks/pubsub/pubsub-cloudevents/#dapr-generated-cloudevents-exampleIn my subscriber I defined an endpoint with a signature like this:
When I tested the endpoint with curl I was confused to receive a 415 error, eventhough the
Content-Typeheader of my request was set toapplication/cloudevents+json. I did some digging and found the reason to beio.quarkiverse.dapr.resteasy.CloudEventReader´, specificallygetCloudEventthat reads thedatacontenttype. This method only acceptsapplication/json,text/plain, andapplication/octet-stream`.To work around my issue, I tried setting the
datacontenttypetotext/plain, but was unsuccessful. I then gotParseException. I think this is because my data is not valid JSON andObjectMapper#readValueis called with a simple type ofCloudEvent<String>, and notString?In the end, I can work around this issue by base64 encoding my XML and setting it in
data_base64instead, but it adds overhead to the transfer. I also think it would be useful for this extension to support more than the three aforementioned media types.