Search in sources :

Example 31 with Request

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);
}
Also used : FutureListener(com.weibo.api.motan.rpc.FutureListener) User(com.weibo.motan.demo.service.model.User) Request(com.weibo.api.motan.rpc.Request) Future(com.weibo.api.motan.rpc.Future) ResponseFuture(com.weibo.api.motan.rpc.ResponseFuture) ResponseFuture(com.weibo.api.motan.rpc.ResponseFuture)

Aggregations

Request (com.weibo.api.motan.rpc.Request)31 DefaultRequest (com.weibo.api.motan.rpc.DefaultRequest)12 Expectations (org.jmock.Expectations)12 Response (com.weibo.api.motan.rpc.Response)10 IHello (com.weibo.api.motan.protocol.example.IHello)9 URL (com.weibo.api.motan.rpc.URL)9 Test (org.junit.Test)9 DefaultResponse (com.weibo.api.motan.rpc.DefaultResponse)7 MotanServiceException (com.weibo.api.motan.exception.MotanServiceException)6 Referer (com.weibo.api.motan.rpc.Referer)5 HashMap (java.util.HashMap)5 RegistryService (com.weibo.api.motan.registry.RegistryService)4 MotanFrameworkException (com.weibo.api.motan.exception.MotanFrameworkException)3 IWorld (com.weibo.api.motan.protocol.example.IWorld)3 Channel (com.weibo.api.motan.transport.Channel)3 MessageHandler (com.weibo.api.motan.transport.MessageHandler)3 YarRequest (com.weibo.yar.YarRequest)3 ArrayList (java.util.ArrayList)3 Serialization (com.weibo.api.motan.codec.Serialization)2 IOException (java.io.IOException)2