Grpc 与 Spring Camel Web 应用程序集成

发布于 2025-01-11 11:53:51 字数 1981 浏览 0 评论 0原文

我有一个基于 spring-camel 的网络服务。我正在尝试使用 grpc-spring-boot-starter 集成 grpc 服务器。我的 grpc 服务的实现如下。

@GrpcService
public class GreetingServiceImpl extends GreetingServiceGrpc.GreetingServiceImplBase {

    @Override
    public void processGrpcRequest(GreetingRequest request, StreamObserver<GreetingResponse> responseObserver) {

        String receivedMessage = request.getRequest();

        GreetingResponse response = GreetingResponse.newBuilder()
                .setResponse("Your message received " + receivedMessage).build();

        responseObserver.onNext(response);
        responseObserver.onCompleted();
    }

}

我将 Web 服务打包为 war,并且在应用程序服务器中部署 war 文件期间没有发现任何错误。但是,当我尝试与 grpc 服务器通信时,收到以下错误消息。

Exception in thread "main" 15:18:01.363 [grpc-nio-worker-ELG-1-2] DEBUG io.grpc.netty.shaded.io.grpc.netty.NettyClientHandler - [id: 0x02a01ffb, L:/127.0.0.1:56000 - R:localhost/127.0.0.1:9089] INBOUND PING: ack=true bytes=1234
io.grpc.StatusRuntimeException: UNIMPLEMENTED: HTTP status code 404
invalid content-type: text/html
headers: Metadata(:status=404,content-type=text/html,date=Fri, 04 Mar 2022 09:48:01 GMT,content-length=74)
DATA-----------------------------
<html><head><title>Error</title></head><body>404 - Not Found</body></html>
    at io.grpc.stub.ClientCalls.toStatusRuntimeException(ClientCalls.java:262)
    at io.grpc.stub.ClientCalls.getUnchecked(ClientCalls.java:243)
    at io.grpc.stub.ClientCalls.blockingUnaryCall(ClientCalls.java:156)
    at com.test.grpc.GreetingServiceGrpc$GreetingServiceBlockingStub.processGrpcRequest(GreetingServiceGrpc.java:156)
    at com.test.grpc.GrpcClient.main(GrpcClient.java:16)

我用最少的设置重新创建了相同的问题,代码可在此处获取 github 。请任何人帮忙解决这个问题。谢谢

I have a web service built on spring-camel. I am trying to integrate the grpc server using grpc-spring-boot-starter. My implementation of grpc service is as below.

@GrpcService
public class GreetingServiceImpl extends GreetingServiceGrpc.GreetingServiceImplBase {

    @Override
    public void processGrpcRequest(GreetingRequest request, StreamObserver<GreetingResponse> responseObserver) {

        String receivedMessage = request.getRequest();

        GreetingResponse response = GreetingResponse.newBuilder()
                .setResponse("Your message received " + receivedMessage).build();

        responseObserver.onNext(response);
        responseObserver.onCompleted();
    }

}

I package my web service as a war and I find no error during deployement of the war file in my application server. However, when I try to communicate with my grpc server, I get the following error message.

Exception in thread "main" 15:18:01.363 [grpc-nio-worker-ELG-1-2] DEBUG io.grpc.netty.shaded.io.grpc.netty.NettyClientHandler - [id: 0x02a01ffb, L:/127.0.0.1:56000 - R:localhost/127.0.0.1:9089] INBOUND PING: ack=true bytes=1234
io.grpc.StatusRuntimeException: UNIMPLEMENTED: HTTP status code 404
invalid content-type: text/html
headers: Metadata(:status=404,content-type=text/html,date=Fri, 04 Mar 2022 09:48:01 GMT,content-length=74)
DATA-----------------------------
<html><head><title>Error</title></head><body>404 - Not Found</body></html>
    at io.grpc.stub.ClientCalls.toStatusRuntimeException(ClientCalls.java:262)
    at io.grpc.stub.ClientCalls.getUnchecked(ClientCalls.java:243)
    at io.grpc.stub.ClientCalls.blockingUnaryCall(ClientCalls.java:156)
    at com.test.grpc.GreetingServiceGrpc$GreetingServiceBlockingStub.processGrpcRequest(GreetingServiceGrpc.java:156)
    at com.test.grpc.GrpcClient.main(GrpcClient.java:16)

I have recreated the same issue with minimal setup and code is available here github . Please can anyone help on this. Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文