Skip to content

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

@huhao0926

Description

@huhao0926

在生产环境使用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上的微信,但是一直没有通过,所以在这里请教下

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions