3

I'm searching for a way to implement generic gRPC client in java which would allow to execute calls providing .proto definition (or at least relying on generated grpc classes), service and method names as parameters.

Probably you could advice if there are any existing libs/frameworks containing implemented solution of such client in java?

I was able to find only this one in Apache Camel: https://github.com/apache/camel/blob/master/components/camel-grpc/src/main/java/org/apache/camel/component/grpc/GrpcProducer.java. It relies on generated grpc classes and uses utility methods to find necessary stub implementation using service name + method provided https://github.com/apache/camel/blob/master/components/camel-grpc/src/main/java/org/apache/camel/component/grpc/GrpcUtils.java.

and also this post, How to create GRPC client directly from protobuf without compiling it into java code, but this implementation uses ServerReflectionGrpc which is not what I'm looking for.

Do you know any other existing generic java gRPC Client implementations? Or probably a decent way to implement this? Thanks a lot!

Suneli
  • 31
  • 4
  • Can you explain why you would want this? – Louis Wasserman Feb 01 '21 at 21:37
  • There is a custom workflow engine which currently supports http calls, where clients are able to configure url/headers/retry options. This needs to be extended to support grpc calls as well. So that users of workflow engine could specify grpc host/port, serviceName/operation and it'll be invoked. The workflow engine itself has no knowledge about client .proto types. – Suneli Feb 01 '21 at 22:23
  • 1
    You might be interested in https://github.com/grpc/grpc-java/compare/v1.6.1...ejona86:grpc-proxy which just treats messages a opaque bytes. Also, don't discount "How to create GRPC client directly from protobuf without compiling it into java code" as server reflection is basically just one possible way to get "descriptors" (the .proto file encoded in binary proto). Generated code also has them; you basically just have one fewer steps if you have the generated code already available. – Eric Anderson Feb 01 '21 at 22:39
  • Thank you, Eric! Just was hoping that it's quite common usecase and there's already some plugable out-of-the-box solution :) – Suneli Feb 01 '21 at 23:42

0 Answers0