Spring / Spring gRPC Interview Questions
How do you create and inject a gRPC client stub in Spring?
With the community starter, you declare a stub field annotated with @GrpcClient("service-name"):
@GrpcClient("order-service") private OrderServiceGrpc.OrderServiceBlockingStub orderStub;
The target address is configured separately, e.g. grpc.client.order-service.address=static://localhost:9090. Spring resolves the named client configuration, builds and manages the underlying ManagedChannel, and injects a ready-to-use stub - no manual channel-building boilerplate is required in application code, and the channel is reused across calls rather than recreated each time.
More Related questions...