Spring / Spring gRPC Interview Questions
What is a ServerInterceptor in gRPC, and what is it typically used for?
A ServerInterceptor wraps every incoming call before it reaches your service method, similar in role to a servlet filter in a traditional web stack. It's the natural place for cross-cutting concerns: authentication/authorization checks, structured logging, metrics collection, or metadata inspection/modification.
In the community Spring starter, you can register one globally by annotating a bean with @GrpcGlobalServerInterceptor, or attach it to specific services. Because interceptors run before your business logic executes, they're also a natural place to reject malformed or unauthorized calls early with an appropriate Status, without that logic being duplicated inside every service method.
More Related questions...