-
Notifications
You must be signed in to change notification settings - Fork 19
Description
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.