Can't use GlobalInterceptor gRPC annotation with interceptor produced by a method
See original GitHub issueDescribe the bug
I have a server interceptor produced by a method:
@Produces
public ServerInterceptor serverInterceptor() {
return new LoggingServerInterceptor();
}
I want to make it global by putting io.quarkus.grpc.GlobalInterceptor annotation.
I can’t put this annotation on the producer method, because the annotation has @Target({ FIELD, PARAMETER, TYPE })
(not applicable to methods).
And I can’t put this annotation on LoggingServerInterceptor class, because the class does not have any CDI bean annotations on it. Quarkus complains:
2021-11-11 04:23:49,640 ERROR [io.qua.grp.run.GrpcServerRecorder] (main) Unable to start the gRPC server: java.lang.IllegalArgumentException: Server interceptor class class com.azul.cc.infrastructure.grpc.LoggingServerInterceptor is not a CDI bean. Only CDI beans can be used as gRPC server interceptors. Add one of the scope-defining annotations (@Singleton, @ApplicationScoped, @RequestScoped) on the interceptor class.
Expected behavior
The GlobalInterceptor annotation should support this case as well.
Actual behavior
No response
How to Reproduce?
No response
Output of uname -a
or ver
No response
Output of java -version
No response
GraalVM version (if different from Java)
No response
Quarkus version or git rev
2.4.1.Final
Build tool (ie. output of mvnw --version
or gradlew --version
)
No response
Additional information
No response
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
java - How to add global exception interceptor in gRPC server?
To install an interceptor for all services on a server, you can use ServerBuilder.intercept() , which was added in gRPC 1.5.0.
Read more >Implementing a gRPC Service - Quarkus
To apply an interceptor to all exposed services, annotate it with @io.quarkus.grpc.GlobalInterceptor . To apply an interceptor to a single service, register it ......
Read more >Configuration | grpc-spring-boot-starter - GitHub Pages
Define the ClientInterceptor as a global interceptor using either the @GrpcGlobalClientInterceptor annotation, or a GlobalClientInterceptorConfigurer ...
Read more >Interceptors in gRPC-Web
Stream interceptor example · Create a ClientReadableStream -wrapper class, and use it to intercept stream events such as the reception of server ...
Read more >Interceptors | NestJS - A progressive Node.js framework
An interceptor is a class annotated with the @Injectable() decorator and ... up a global interceptor, we use the useGlobalInterceptors() method of the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I understand it’s more convenient in some cases, I’m not closing this issue. What I wanted to say is that, having a work around, and being non-trivial, I don’t consider this a high priority feature request.
I stumbled on this issue and I was wondering, would it be possible to use the
Produces
annotation at least for service scoped interceptors? It would be nice to reuse existing interceptors without wrapping them in new classes.