Lately, I 'm studying to build the gRPC client-server interaction.
I wrote a gRPC service :
service SearchService {
rpc Find (SearchReq) returns (SearchRes);
}
and then I should invoke it on the client side using stub(another java-application).
whats the difference between this two types of stubs??
SearchServiceGrpc.SearchServiceFutureStub futureStub = SearchServiceGrpc.newFutureStub(channel);
SearchServiceGrpc.SearchServiceBlockingStub blockingStub = SearchServiceGrpc.newBlockingStub(channel);
blockingStub.find(request);
- for blocking
futureStub.find(request).get();
- for future
I understand how works Futures in java, but I don't understand what happens inside gRPC and what type of stubs invocation is more productive
I find no information on google about it.
Thanks!
The various stubs are implemented using the same async API (ClientCall). Your choice doesn't matter for the grpc internals.
But the APIs have the normal expected limitations. For example: if you use blocking, that thread cannot be used until the RPC completes.