Package com.alibaba.dubbo.remoting.exchange

Examples of com.alibaba.dubbo.remoting.exchange.ResponseFuture


    }
   
    private void asyncCallback(final Invoker<?> invoker, final Invocation invocation) {
        Future<?> f = RpcContext.getContext().getFuture();
        if (f instanceof FutureAdapter) {
            ResponseFuture future = ((FutureAdapter<?>)f).getFuture();
            future.setCallback(new ResponseCallback() {
                public void done(Object rpcResult) {
                    if (rpcResult == null){
                        logger.error(new IllegalStateException("invalid result value : null, expected "+Result.class.getName()));
                        return;
                    }
View Full Code Here


              boolean isSent = getUrl().getMethodParameter(methodName, Constants.SENT_KEY, false);
                currentClient.send(inv, isSent);
                RpcContext.getContext().setFuture(null);
                return new RpcResult();
            } else if (isAsync) {
              ResponseFuture future = currentClient.request(inv, timeout) ;
                RpcContext.getContext().setFuture(new FutureAdapter<Object>(future));
                return new RpcResult();
            } else {
              RpcContext.getContext().setFuture(null);
                return (Result) currentClient.request(inv, timeout).get();
View Full Code Here

        }
    }

    @Test
    public void testFuture() throws Exception {
        ResponseFuture future = client.request(new World("world"));
        Hello result = (Hello)future.get();
        Assert.assertEquals("hello,world", result.getName());
    }
View Full Code Here

        }
    }

    @Test
    public void testFuture() throws Exception {
        ResponseFuture future = client.request(new World("world"));
        Hello result = (Hello)future.get();
        Assert.assertEquals("hello,world", result.getName());
    }
View Full Code Here

    for(int i=0;i<100;i++)
      client.request(new Main.Data());

    System.out.println("=====test invoke=====");
    for(int i=0;i<100;i++){
      ResponseFuture future = client.request(new Main.Data());
      System.out.println("invoke and get");
      System.out.println("invoke result:" + future.get());
    }
    System.out.println("=====the end=====");
  }
View Full Code Here

        return request(msg, 0);
    }

    public ResponseFuture request(Object msg, int timeout) throws RemotingException {
        this.invoked = msg;
        return new ResponseFuture() {
            public Object get() throws RemotingException {
                return received;
            }
            public Object get(int timeoutInMillis) throws RemotingException {
                return received;
View Full Code Here

              boolean isSent = getUrl().getMethodParameter(methodName, Constants.SENT_KEY, false);
                currentClient.send(inv, isSent);
                RpcContext.getContext().setFuture(null);
                return new RpcResult();
            } else if (isAsync) {
              ResponseFuture future = currentClient.request(inv, timeout) ;
                RpcContext.getContext().setFuture(new FutureAdapter<Object>(future));
                return new RpcResult();
            } else {
              RpcContext.getContext().setFuture(null);
                return (Result) currentClient.request(inv, timeout).get();
View Full Code Here

            boolean isAsync = getUrl().getMethodParameter(methodName, Constants.ASYNC_KEY, false);
            int timeout = getUrl().getMethodParameter(methodName, Constants.TIMEOUT_KEY,Constants.DEFAULT_TIMEOUT);
            if (isAsync) {
                boolean isReturn = getUrl().getMethodParameter(methodName, RpcConstants.RETURN_KEY, true);
                if (isReturn) {
                    ResponseFuture future = currentClient.request(inv, timeout) ;
                    RpcContext.getContext().setFuture(new FutureAdapter<Object>(future));
                } else {
                    boolean isSent = getUrl().getMethodParameter(methodName, Constants.SENT_KEY, false);
                    currentClient.send(inv, isSent);
                    RpcContext.getContext().setFuture(null);
View Full Code Here

    }
   
    private void asyncCallback(final Invoker<?> invoker, final Invocation invocation) {
        Future<?> f = RpcContext.getContext().getFuture();
        if (f instanceof FutureAdapter) {
            ResponseFuture future = ((FutureAdapter<?>)f).getFuture();
            future.setCallback(new ResponseCallback() {
                public void done(Object rpcResult) {
                    if (rpcResult == null){
                        logger.error(new IllegalStateException("invalid result value : null, expected "+Result.class.getName()));
                        return;
                    }
View Full Code Here

            boolean isAsync = getUrl().getMethodParameter(methodName, Constants.ASYNC_KEY, false);
            int timeout = getUrl().getMethodParameter(methodName, Constants.TIMEOUT_KEY,Constants.DEFAULT_TIMEOUT);
            if (isAsync) {
                boolean isReturn = getUrl().getMethodParameter(methodName, Constants.RETURN_KEY, true);
                if (isReturn) {
                    ResponseFuture future = currentClient.request(inv, timeout) ;
                    RpcContext.getContext().setFuture(new FutureAdapter<Object>(future));
                } else {
                    boolean isSent = getUrl().getMethodParameter(methodName, Constants.SENT_KEY, false);
                    currentClient.send(inv, isSent);
                    RpcContext.getContext().setFuture(null);
View Full Code Here

TOP

Related Classes of com.alibaba.dubbo.remoting.exchange.ResponseFuture

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.