use of com.alipay.hessian.generic.model.GenericObject in project sofa-rpc by sofastack.
the class GenericClientMain method main.
public static void main(String[] args) {
ApplicationConfig applicationConfig = new ApplicationConfig().setAppName("generic-client");
ConsumerConfig<GenericService> consumerConfig = new ConsumerConfig<GenericService>().setApplication(applicationConfig).setInterfaceId(TestGenericService.class.getName()).setGeneric(true).setTimeout(50000).setDirectUrl("bolt://127.0.0.1:22222?appName=generic-server");
GenericService testService = consumerConfig.refer();
LOGGER.warn("started at pid {}", RpcRuntimeContext.PID);
while (true) {
try {
String s1 = (String) testService.$invoke("echoStr", new String[] { "java.lang.String" }, new Object[] { "1111" });
LOGGER.warn("generic return :{}", s1);
GenericObject genericObject = new GenericObject("com.alipay.sofa.rpc.invoke.generic.TestObj");
genericObject.putField("str", "xxxx");
genericObject.putField("num", 222);
GenericObject o2 = (GenericObject) testService.$genericInvoke("echoObj", new String[] { "com.alipay.sofa.rpc.invoke.generic.TestObj" }, new Object[] { genericObject });
LOGGER.warn("generic return :{}", o2);
TestObj o3 = testService.$genericInvoke("echoObj", new String[] { "com.alipay.sofa.rpc.invoke.generic.TestObj" }, new Object[] { genericObject }, TestObj.class);
LOGGER.warn("generic return :{}", o3);
} catch (Exception e) {
LOGGER.error(e.getMessage(), e);
}
try {
Thread.sleep(2000);
} catch (Exception ignore) {
}
}
}
Aggregations