Quarkus GRPC客户注入
我正在尝试通过@grpcclient
在文档中写入GRPC服务,并且在我在客户端Microservice上调用端点时,它具有Runtime nullpoInterException
“不满意的依赖性:不匹配注入点” 。如果我实例化mutiny存根和手动频道,则可以按预期工作。使用MVN Compile
和Quarkus.generate.grpc.scan-for-imports =所有
我已经完成了,因此生成的类和接口存在于target。 -sources.grpc。< package-name>
路径。
数据客户
class PlatformDataClientImpl {
// @Inject with this does not work as well
@GrpcClient("baz")
GrpcPlatform baz;
public Uni<List<Platform>> getAllPlatforms() {
return baz
.getAllPlatforms(PlatformProto.GetAllRequest.newBuilder().build())
.onItem()
.transform(platformResponse -> platformResponse
.getPlatformList()
.stream()
.map(this::transformPlatform)
.collect(Collectors.toList())
);
}
}
追踪
2022-07-09 14:03:25,390 ERROR [org.jbo.res.rea.com.cor.AbstractResteasyReactiveContext] (vert.x-eventloop-thread-1) Request failed: java.lang.NullPointerException: Cannot invoke "com.kahnwald.command.GrpcPlatform.getAllPlatforms(com.kahnwald.command.PlatformProto$GetAllRequest)" because "this.baz" is null
at com.kahnwald.command.data.clients.PlatformDataClientImpl.getAllPlatforms(PlatformDataClientImpl.java:21)
at com.kahnwald.command.ExampleResource.gTest(ExampleResource.java:28)
at com.kahnwald.command.ExampleResource_Subclass.gTest$$superforward1(Unknown Source)
at com.kahnwald.command.ExampleResource_Subclass$$function$$1.apply(Unknown Source)
at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:54)
at io.quarkus.arc.runtime.devconsole.InvocationInterceptor.proceed(InvocationInterceptor.java:62)
at io.quarkus.arc.runtime.devconsole.InvocationInterceptor.monitor(InvocationInterceptor.java:49)
at io.quarkus.arc.runtime.devconsole.InvocationInterceptor_Bean.intercept(Unknown Source)
at io.quarkus.arc.impl.InterceptorInvocation.invoke(InterceptorInvocation.java:41)
at io.quarkus.arc.impl.AroundInvokeInvocationContext.perform(AroundInvokeInvocationContext.java:41)
at io.quarkus.arc.impl.InvocationContexts.performAroundInvoke(InvocationContexts.java:32)
at com.kahnwald.command.ExampleResource_Subclass.gTest(Unknown Source)
at com.kahnwald.command.ExampleResource$quarkusrestinvoker$gTest_3bdd2c95d9fa1dda6e9fab2c52cbe4fe8e995401.invoke(Unknown Source)
at org.jboss.resteasy.reactive.server.handlers.InvocationHandler.handle(InvocationHandler.java:29)
at io.quarkus.resteasy.reactive.server.runtime.QuarkusResteasyReactiveRequestContext.invokeHandler(QuarkusResteasyReactiveRequestContext.java:108)
at org.jboss.resteasy.reactive.common.core.AbstractResteasyReactiveContext.run(AbstractResteasyReactiveContext.java:141)
at org.jboss.resteasy.reactive.server.handlers.RestInitialHandler.beginProcessing(RestInitialHandler.java:49)
at org.jboss.resteasy.reactive.server.vertx.ResteasyReactiveVertxHandler.handle(ResteasyReactiveVertxHandler.java:17)
at org.jboss.resteasy.reactive.server.vertx.ResteasyReactiveVertxHandler.handle(ResteasyReactiveVertxHandler.java:7)
at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1212)
at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:163)
at io.vertx.ext.web.impl.RoutingContextImpl.next(RoutingContextImpl.java:141)
at io.quarkus.vertx.http.runtime.StaticResourcesRecorder$2.handle(StaticResourcesRecorder.java:83)
at io.quarkus.vertx.http.runtime.StaticResourcesRecorder$2.handle(StaticResourcesRecorder.java:67)
at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1212)
at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:126)
at io.vertx.ext.web.impl.RoutingContextImpl.next(RoutingContextImpl.java:141)
at io.vertx.ext.web.handler.impl.StaticHandlerImpl.lambda$sendStatic$1(StaticHandlerImpl.java:274)
at io.vertx.core.impl.future.FutureImpl$3.onSuccess(FutureImpl.java:141)
at io.vertx.core.impl.future.FutureBase.lambda$emitSuccess$0(FutureBase.java:54)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:469)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:503)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:833)
可以描述我错过或做错了什么?我需要在客户端或其他方面实施服务吗?
Quarkus版本:2.9.2.Final
I'm trying to inject my grpc service via @GrpcClient
as it is written in the documentation and have runtime NullPointerException
when I call an endpoint on my client microservice because "Unsatisfied dependency: no bean matches the injection point". If I instantiate mutiny stub and channel manually it works as expected. With mvn compile
and quarkus.generate-code.grpc.scan-for-imports=all
I have done, so generated classes and interfaces exist in target.generated-sources.grpc.<package-name>
path.
Data client
class PlatformDataClientImpl {
// @Inject with this does not work as well
@GrpcClient("baz")
GrpcPlatform baz;
public Uni<List<Platform>> getAllPlatforms() {
return baz
.getAllPlatforms(PlatformProto.GetAllRequest.newBuilder().build())
.onItem()
.transform(platformResponse -> platformResponse
.getPlatformList()
.stream()
.map(this::transformPlatform)
.collect(Collectors.toList())
);
}
}
Traceback
2022-07-09 14:03:25,390 ERROR [org.jbo.res.rea.com.cor.AbstractResteasyReactiveContext] (vert.x-eventloop-thread-1) Request failed: java.lang.NullPointerException: Cannot invoke "com.kahnwald.command.GrpcPlatform.getAllPlatforms(com.kahnwald.command.PlatformProto$GetAllRequest)" because "this.baz" is null
at com.kahnwald.command.data.clients.PlatformDataClientImpl.getAllPlatforms(PlatformDataClientImpl.java:21)
at com.kahnwald.command.ExampleResource.gTest(ExampleResource.java:28)
at com.kahnwald.command.ExampleResource_Subclass.gTest$superforward1(Unknown Source)
at com.kahnwald.command.ExampleResource_Subclass$function$1.apply(Unknown Source)
at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:54)
at io.quarkus.arc.runtime.devconsole.InvocationInterceptor.proceed(InvocationInterceptor.java:62)
at io.quarkus.arc.runtime.devconsole.InvocationInterceptor.monitor(InvocationInterceptor.java:49)
at io.quarkus.arc.runtime.devconsole.InvocationInterceptor_Bean.intercept(Unknown Source)
at io.quarkus.arc.impl.InterceptorInvocation.invoke(InterceptorInvocation.java:41)
at io.quarkus.arc.impl.AroundInvokeInvocationContext.perform(AroundInvokeInvocationContext.java:41)
at io.quarkus.arc.impl.InvocationContexts.performAroundInvoke(InvocationContexts.java:32)
at com.kahnwald.command.ExampleResource_Subclass.gTest(Unknown Source)
at com.kahnwald.command.ExampleResource$quarkusrestinvoker$gTest_3bdd2c95d9fa1dda6e9fab2c52cbe4fe8e995401.invoke(Unknown Source)
at org.jboss.resteasy.reactive.server.handlers.InvocationHandler.handle(InvocationHandler.java:29)
at io.quarkus.resteasy.reactive.server.runtime.QuarkusResteasyReactiveRequestContext.invokeHandler(QuarkusResteasyReactiveRequestContext.java:108)
at org.jboss.resteasy.reactive.common.core.AbstractResteasyReactiveContext.run(AbstractResteasyReactiveContext.java:141)
at org.jboss.resteasy.reactive.server.handlers.RestInitialHandler.beginProcessing(RestInitialHandler.java:49)
at org.jboss.resteasy.reactive.server.vertx.ResteasyReactiveVertxHandler.handle(ResteasyReactiveVertxHandler.java:17)
at org.jboss.resteasy.reactive.server.vertx.ResteasyReactiveVertxHandler.handle(ResteasyReactiveVertxHandler.java:7)
at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1212)
at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:163)
at io.vertx.ext.web.impl.RoutingContextImpl.next(RoutingContextImpl.java:141)
at io.quarkus.vertx.http.runtime.StaticResourcesRecorder$2.handle(StaticResourcesRecorder.java:83)
at io.quarkus.vertx.http.runtime.StaticResourcesRecorder$2.handle(StaticResourcesRecorder.java:67)
at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1212)
at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:126)
at io.vertx.ext.web.impl.RoutingContextImpl.next(RoutingContextImpl.java:141)
at io.vertx.ext.web.handler.impl.StaticHandlerImpl.lambda$sendStatic$1(StaticHandlerImpl.java:274)
at io.vertx.core.impl.future.FutureImpl$3.onSuccess(FutureImpl.java:141)
at io.vertx.core.impl.future.FutureBase.lambda$emitSuccess$0(FutureBase.java:54)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:469)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:503)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:833)
Could anybody describe what I missed or do wrong? Do I need to implement services on client side or something?
Quarkus version: 2.9.2.Final
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论