Skip to content

Support taking an ObjectSerializer as well on pubsub message handling #597

Open
@CodeMonkeyLeet

Description

@CodeMonkeyLeet

Describe the proposal

Porting a suggestion from user bencod#6730 in Dapr Discord:

On publishing, Dapr client accepts message data as Object and it serialize the Object using ObjectSerializer - the Dapr one or user provided one.

On message handling user receives a CloudEvent that has data which according to documentation is String or Json, or the binary data of the message.

It requires user to deserialize the message. This behavior is not consistent with publishing serialization which is done by client.
I would expect deserialization to be done by infra as well, to allow user to provide an ObjectSerializer and CloudEvent to be typed. Something as follows:

@Topic(name = "testTopic", pubsubName = "testPubSub", serializer = MyMsgObjectSerializer.class)
public Mono<Void> handleMessage(@RequestBody(required = false) CloudEvent<MyMsg> cloudEvent) {
   ...
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions