Open akorkiatupa opened 1 year ago
The UseCloudEvents
middleware is strongly tied to the event actually being the exact format of CloudEvent
that Dapr sends. When I've used raw messages in the past, what I've done is just have the endpoint take an object that the data can be deserialzied into and accessed data in the handler and done the deserialization there. You could do this with your own middleware too if you want a slightly nicer experience.
Ok, thanks for the tip. That's what I thought, ended up writing custom handler with ServiceBus SDK
so we can have indented communication between Dapr instances using pubsub with CloudEvents
utilizing UseCloudEvents
middleware.
As a developer It would be nice if UseCloudEvents
could co-exist with endpoints using rawPayload
s. Then you would have the flexibility to use rawPayload
s with some lecagy brokers without known json schema and CloudEvents
normally if you don't explicitly tell to Dapr SDK
to listen topic subscription with rawPayload
.
Yeah, it's something I've thought about as well. I don't think it'd be that hard to add an optional filter into the UseCloudEvents
middleware to skip parsing certain topics.
Expected Behavior
When publishing and receiving events through pubsub component using rawPayload=true, receiving subscriber endpoint should be able to deserialize response body into a valid object.
Actual Behavior
When receiving events from topic subscriber where enableRawPayload=true and message was sent with rawPayload=true with Content-Type of application/json, the receiving end throws an exception from the useCloudEvents middleware.
Or when the app.UseCloudEvents() middleware is completely removed the source binding binds the data as null. When using streamReader to read the request.Body it is:
Steps to Reproduce the Problem
Configure startup with app.UseCloudEvents(); Publish messages where rawPayload=true set up a subscriber with enableRawPayload = true.
Questions
How raw payloads should be deserialized? There is so little information about how to use pubsub without CloudEvents as rawPayload messages, especially for the AspNetCore SDK. I am starting to feel like using ServiceBus SDK to receive messages outside of dapr cluster.