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

Java serialized Objects over gRPC #11921

Open
ndovidio opened this issue Feb 23, 2025 · 1 comment
Open

Java serialized Objects over gRPC #11921

ndovidio opened this issue Feb 23, 2025 · 1 comment
Labels

Comments

@ndovidio
Copy link

Hello, I have a large number of servers which all utilize native Java serialization for communication over an in house networking layer.

I'm evaluating replacing our in house networking layer/RPC code with that generated by gRPC. I'm attempting to avoid making .proto files for all of these objects since many of them are complex with deep and nested composition. Moreover the sheer scale of the objects involved make the project difficult from a testing standpoint. In a later/future state I expect us to use .protos/gRPC for the rare non-java based process communication.

What is the suggested way of attempting this migration? Is basing it off the JSON setup described here (#5048) still the preferred mechanism? If anyone has related sample code it will be greatly appreciated.

Thank you

@kannanjgithub
Copy link
Contributor

kannanjgithub commented Feb 26, 2025

Yes, the JSON setup example is preferred mechanism for how to use custom serialization (and encoding) by creating Marshallers for the request and response types. The JSON setup example however quotes a handwritten RPC invocation rather than use a stub generated using the protoc-gen-grpc plugin for codegen.
If you are planning to use the codegen know that it need a service proto that uses protos for request and responses, that you are trying to avoid right now. The best way may be to use a gRPC codegen generated stubs for a simple HelloWorld service as a reference, and replace the Marshallers used in the method descriptors. To avoid handwriting this modified stub for every service, you can make your own simple codegen (either generating code or a annotation processor) or using something like java.lang.reflect.Proxy. Your users could define a Java interface for the RPC, with annotations if necessary, and then your codegen/Proxy would fill in the stub.

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

No branches or pull requests

2 participants