-
Notifications
You must be signed in to change notification settings - Fork 286
Description
在生产环境使用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上的微信,但是一直没有通过,所以在这里请教下