use of com.alipay.sofa.rpc.asynchain.ServiceB in project sofa-rpc by sofastack.
the class ServerB method main.
public static void main(String[] args) {
// B服务里的C服务客户端
ConsumerConfig<ServiceC> consumerConfig = new ConsumerConfig<ServiceC>().setApplication(new ApplicationConfig().setAppName("BBB")).setInterfaceId(ServiceC.class.getName()).setDirectUrl("bolt://127.0.0.1:12299?appName=CCC").setRegister(false).setInvokeType(// 不设置,调用级别可设置
"callback").setTimeout(2000);
ServiceC serviceC = consumerConfig.refer();
ServerConfig serverConfig = new ServerConfig().setPort(12298).setDaemon(false);
ProviderConfig<ServiceB> providerConfig = new ProviderConfig<ServiceB>().setInterfaceId(ServiceB.class.getName()).setApplication(new ApplicationConfig().setAppName("BBB")).setRef(new ServiceBImpl(serviceC)).setServer(serverConfig).setRegister(false);
providerConfig.export();
}
use of com.alipay.sofa.rpc.asynchain.ServiceB in project sofa-rpc by sofastack.
the class ClientA method main.
public static void main(String[] args) {
// A 服务
ConsumerConfig<ServiceB> consumerConfig = new ConsumerConfig<ServiceB>().setApplication(new ApplicationConfig().setAppName("AAA")).setInterfaceId(ServiceB.class.getName()).setDirectUrl("bolt://127.0.0.1:12298?appName=BBB").setRegister(false).setTimeout(3000);
ServiceB serviceB = consumerConfig.refer();
while (true) {
try {
int ret0 = serviceB.getInt(999);
LOGGER.info("ret0:" + ret0);
} catch (Exception e) {
e.printStackTrace();
}
try {
Thread.sleep(3000);
} catch (Exception e) {
}
}
}
Aggregations