Skip to content

Automatically unwrap pub/sub CloudEvent #576

@mthmulders

Description

@mthmulders

Automatically unwrap pub/sub CloudEvent

Background

In the Dapr SDK for .NET, one can configure the SDK to automatically unwrap CloudEvents that an application receives over pub/sub using app.UseCloudEvents().

The Dapr SDK for Java, however, only lets you receive a CloudEvent. It provides access to the underlying message using getData, but that method returns an Object. According to the specs, this can be a JSON object or string. This means in practice it can be anything - for complex types, it will most likely be a java.util.Map.

Proposal

It would be cool if the SDK for Java would allow to unwrap a CloudEvent in the same way as the SDK for .NET does.

Alternatives

As an alternative, if the CloudEvent class would be a generic class with one type parameter that describes the type of the data, field, it would at least make it a lot easier to unwrap the CloudEvent by declaring it of the right type and then calling getData() on it. I did a quick & dirty PoC by copying the CloudEvent class into my application and making it generic, and Jackson (the default serializer) seems to handle perfectly well.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions