将GRPC服务方法用于每种方法的不同端口,而不是一个端口的整个应用程序

发布于 2025-02-07 16:29:26 字数 1036 浏览 0 评论 0原文

@GRpcService
public class GRPCServiceImpl extends Grpc.ImplBase {

    @Override
    public void updateDetail(UpdateDetail.UpdateDetailRequest request, StreamObserver<UpdateDetail.UpdateDetailResponse> responseObserver) {
    
    }

    @Override
    public void profileUpdate(Update.UpdateRequest request, StreamObserver<Update.UpdateResponse> responseObserver) {
      
    }

    @Override
    public void update(Update.UpdateRequest request, StreamObserver<Update.UpdateResponse> responseObserver) {

    
}

在我的Spring-Boot应用程序中,我有类似上述课程和方法。有几种方法。此服务以默认端口6565。并通向6565端口,所有这些方法都在执行。我需要这些方法可以用每种方法的端口暴露,因为到达的请求被定向到无法更改的不同端口。因此,不同的方法应使用不同的端口聆听。我不能为每种方法提供很少的应用程序,因为这些方法属于相关任务。

目前,我正在使用以下依赖关系,

<dependency>
<groupId>io.github.lognet</groupId>
<artifactId>grpc-spring-boot-starter</artifactId>
<version>3.0.0</version>
</dependency>

我听说使用Apache Camel可以完成此方法的曝光。是否有其他方法可以保持上述依赖性?还是我可以实现这一目标的任何其他方法?感谢帮助

@GRpcService
public class GRPCServiceImpl extends Grpc.ImplBase {

    @Override
    public void updateDetail(UpdateDetail.UpdateDetailRequest request, StreamObserver<UpdateDetail.UpdateDetailResponse> responseObserver) {
    
    }

    @Override
    public void profileUpdate(Update.UpdateRequest request, StreamObserver<Update.UpdateResponse> responseObserver) {
      
    }

    @Override
    public void update(Update.UpdateRequest request, StreamObserver<Update.UpdateResponse> responseObserver) {

    
}

In my spring-boot application, I have class and methods like the above. There are a few methods. This service is exposed with default port 6565. And with the call to 6565 port, all those methods are executing. I need these methods to expose with a port for each method because coming requests are directed to different ports which cannot be changed. So different methods should be listening with different ports. I cannot have few applications for each method because those methods belong to related tasks.

Currently, I am using the following dependency,

<dependency>
<groupId>io.github.lognet</groupId>
<artifactId>grpc-spring-boot-starter</artifactId>
<version>3.0.0</version>
</dependency>

I heard this method expose thing can be done using apache camel. Is there any other way to do this with keeping the above dependency? or any other ways I can achieve this ?. Appreciate the help

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

对你而言 2025-02-14 16:29:26

如果我正确理解您,您有3种GRPC方法,您想在3个不同的端口中公开。

最好的方法是:

  1. 将3种方法与3种原型分开。 (每个原始方法1方法)
  2. 现在,您可以作为在不同端口上运行的独立服务 /线程开始每个方法。

官方Java Grpc文档

我在python的背景下讲述了这种策略,但也应该适用于其他任何语言。

If I understood you correctly, you have 3 gRPC methods which you want to expose in 3 different ports.

The best way is to:

  1. Separate out 3 methods to 3 protos. (1 method per proto)
  2. Now you can start each of the method as an independent service / thread running on different ports.

Official Java gRPC Docummentation.

I am telling this strategy in context of python, but should work for any other language too.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文