use of com.weibo.api.motan.rpc.Request in project motan by weibocom.
the class Motan2RpcClient method motan2XmlCommonClientDemo.
public static void motan2XmlCommonClientDemo(CommonHandler client) throws Throwable {
System.out.println(client.call("hello", new Object[] { "a" }, String.class));
User user = new User(1, "AAA");
System.out.println(user);
user = (User) client.call("rename", new Object[] { user, "BBB" }, User.class);
System.out.println(user);
ResponseFuture future = (ResponseFuture) client.asyncCall("rename", new Object[] { user, "CCC" }, User.class);
user = (User) future.getValue();
System.out.println(user);
ResponseFuture future2 = (ResponseFuture) client.asyncCall("rename", new Object[] { user, "DDD" }, User.class);
future2.addListener(new FutureListener() {
@Override
public void operationComplete(Future future) {
System.out.println(future.getValue());
}
});
Request request = client.buildRequest("rename", new Object[] { user, "EEE" });
request.setAttachment("a", "a");
user = (User) client.call(request, User.class);
System.out.println(user);
// expect throw exception
// client.call("rename", new Object[]{null, "FFF"}, void.class);
}
Aggregations