When using grpc-java , is there a recommended way to support failover?
For instance, you are connected to one server, which then goes down. What is the recommended way do you recover from that?
I have seen the experimental LoadBalancer
class. Is it intended to solve the problem? There are also various Interceptor classes, but I am not sure how to use them to react on connection errors.
We are using the grpc-spring-boot-starter , but I do not see failover support, there, either.
What I would like to avoid is handling all reconnects in the business classes. For instance, by catching exceptions there and building up a connection to the next available server. If possible that should be handled transparently.
It is not an official dependency
https://github.com/yidongnan/grpc-spring-boot-starter
In client
@GrpcClient("gRPC server name")
private Channel serverChannel;
GreeterGrpc.GreeterBlockingStub stub = GreeterGrpc.newBlockingStub(serverChannel);
HelloReply response = stub.sayHello(HelloRequest.newBuilder().setName(name).build());
The client request will use load balancing.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.