Commit 86a64ec8 by huangfusuper

修改RPC的超时时间

parent b0e75229
......@@ -211,10 +211,12 @@ public class RpcReferenceBean {
// future-response set
RpcFutureResponse futureResponse = new RpcFutureResponse(invokerFactory, rpcRequest, null);
try {
//TODO 改方法需要添加ip测试功能项
// do invoke
client.asyncSend(finalAddress, rpcRequest);
// future get
logger.debug(">>>>>>>>>>>>数据:{},请求:{},的超时时间为:{}",rpcRequest,rpcRequest.getRequestId(),timeout);
RpcResponse rpcResponse = futureResponse.get(timeout, TimeUnit.MILLISECONDS);
if (rpcResponse.getErrorMsg() != null) {
throw new RpcException(rpcResponse.getErrorMsg());
......@@ -231,23 +233,23 @@ public class RpcReferenceBean {
} else if (CallType.FUTURE == callType) {
// future-response set
RpcFutureResponse futureResponse = new RpcFutureResponse(invokerFactory, rpcRequest, null);
try {
// invoke future set
RpcInvokeFuture invokeFuture = new RpcInvokeFuture(futureResponse);
RpcInvokeFuture.setFuture(invokeFuture);
try {
// invoke future set
RpcInvokeFuture invokeFuture = new RpcInvokeFuture(futureResponse);
RpcInvokeFuture.setFuture(invokeFuture);
// do invoke
client.asyncSend(finalAddress, rpcRequest);
// do invoke
client.asyncSend(finalAddress, rpcRequest);
return null;
} catch (Exception e) {
return null;
} catch (Exception e) {
logger.info(">>>>>>>>>>> myth-rpc, invoke error, address:{}, RpcRequest{}", finalAddress, rpcRequest);
// future-response remove
futureResponse.removeInvokerFuture();
throw (e instanceof RpcException)?e:new RpcException(e);
}
}
} else if (CallType.CALLBACK == callType) {
......@@ -276,9 +278,9 @@ return null;
return null;
} else if (CallType.ONEWAY == callType) {
client.asyncSend(finalAddress, rpcRequest);
return null;
} else {
client.asyncSend(finalAddress, rpcRequest);
return null;
} else {
throw new RpcException("myth-rpc callType["+ callType +"] invalid");
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment