Tars 负载均衡

// 传入主控地址,在 db_tars  t_registry_info 表中
        Communicator communicator = CommunicatorFactory.getInstance()
                .getCommunicator("tars.tarsregistry.QueryObj@tcp -h 172.16.0.4 -p 17890");
        // 这里不需要绑定 ip 和端口
        GlobalIdPrx proxy = communicator.stringToProxy(GlobalIdPrx.class, "ICTPAAS.GIDServer.GlobalIdObj");

        String globalId = proxy.getGlobalId("testw");

主控会拉取当前可用的服务来负载均衡,默认是轮询

原文地址:https://www.cnblogs.com/huanggy/p/9636509.html