starlight icon indicating copy to clipboard operation
starlight copied to clipboard

BRPC 启动多个Server监听不同的端口,但是代理相同的endpoint类,会有什么问题

Open huhao0926 opened this issue 5 months ago • 0 comments

在生产环境使用Brpc服务,启动多个Server,监听不同端口,代理相同的endpoint。

public class EchoServiceImpl implements EchoService { private static final Logger LOG = LoggerFactory.getLogger(EchoServiceImpl.class);

private String name; public EchoServiceImpl(String name) {this.name = name;} @Override public Echo.EchoResponse echo(Echo.EchoRequest request) { LOG.info("my name is " + name); return response; } }

RpcServer rpcServer1 = new RpcServer(8000, RpcOptionsUtils.getRpcServerOptions()); rpcServer1.registerService(new EchoServiceImpl("a")); rpcServer1.start();

RpcServer rpcServer2 = new RpcServer(8001, RpcOptionsUtils.getRpcServerOptions()); rpcServer2.registerService(new EchoServiceImpl("b"), RpcOptionsUtils.getRpcServerOptions()); rpcServer2.start();

请求的时候,无论请求哪个server的地址,发现永远是最后一次new 出来rpcEndpoint对象在处理,其他监听的端口没有任何作用,上面的输出永远是"my name is b"

加了github上的微信,但是一直没有通过,所以在这里请教下

huhao0926 avatar Jul 08 '25 06:07 huhao0926