Spring / Spring gRPC Interview Questions
What are the four types of service methods gRPC supports?
A gRPC service method can be declared as one of four call shapes in the .proto file:
- Unary RPC - one request, one response, like a normal method call.
- Server streaming RPC - one request, a stream of responses.
- Client streaming RPC - a stream of requests, one final response.
- Bidirectional streaming RPC - both sides send independent streams of messages over the same connection.
The shape is declared with the stream keyword on the request and/or response type in the .proto definition, and the generated Java stub method signature changes accordingly (a simple return value for unary, versus StreamObserver-based signatures for the streaming variants).
flowchart LR A[Unary: 1 req -> 1 res] B[Server streaming: 1 req -> N res] C[Client streaming: N req -> 1 res] D[Bidirectional: N req -> N res]
More Related questions...