Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Serialization in Java SDK 1.10 for MongoDB #942

Open
manuraf opened this issue Oct 28, 2023 · 2 comments
Open

Custom Serialization in Java SDK 1.10 for MongoDB #942

manuraf opened this issue Oct 28, 2023 · 2 comments

Comments

@manuraf
Copy link

manuraf commented Oct 28, 2023

Hello,

I'm currently working with Java SDK 1.10 to store a POJO in MongoDB, and I've encountered an issue with the default serialization. When I save the POJO, the result is stored as a string in MongoDB, like this:

value: '{product: "prod", name: "example"}'

I attempted to create a custom serialization using a Jackson object mapper, but unfortunately, the result remains the same:

OBJECT_MAPPER.writeAsByte(pojo)

What I'm aiming for is to have the POJO stored as an object in MongoDB, like this:

value: {
  product: "prod",
  name: "example"
}
@artursouza
Copy link
Member

Please, look at the query state example: https://github.com/dapr/java-sdk/blob/master/examples/src/main/java/io/dapr/examples/querystate/README.md

It uses MongoDB and saves the data in a queryable format.

@xduseko
Copy link

xduseko commented Jan 16, 2024

Same problem here. It seems that DAPR is able to save state as JSON (queryable format) only using HTTP API protocol. It is also used in the demo @artursouza linked.

-Ddapr.api.protocol=HTTP

Unfortunately HTTP API protocol is marked as deprecated in the Java SDK so it's not a very good workaround. It would be nice to have it working with the default gRPC protocol.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants