use of com.duangframework.rpc.common.RpcResponse in project duangframework by tcrct.
the class RpcClientProxy method doProxy.
@Override
public Object doProxy(ProxyChain proxyChain) throws Exception {
Method method = proxyChain.getTargetMethod();
Class<?> targetClass = proxyChain.getTargetClass();
// 发现服务
RpcAction action = RpcFactory.discoverService(targetClass);
if (ToolsKit.isEmpty(action)) {
throw new RpcException("Can't Discover " + targetClass.getName() + " RpcAction! Please Check ZooKeep Server");
}
// 创建并初始化 RPC 请求
RpcRequest request = new RpcRequest(System.currentTimeMillis(), RpcUtils.getRequestId());
request.setIface(targetClass.getName());
request.setMethodName(method.getName());
request.setParameterTypes(method.getParameterTypes());
request.setParameters(proxyChain.getMethodParams());
request.setService(action.getService().getName());
logger.warn("[" + RpcUtils.formatDate(request.getStartTime()) + "] request[" + request.getRequestId() + "] [" + action.getRemoteip() + "/" + action.getIntranetip() + ":" + action.getPort() + "] " + request.getIface() + "." + request.getMethodName());
RpcResponse response = RpcClient.getInstance().call(request, action);
if (response != null) {
if (response.isError()) {
logger.warn("response error:" + response.getError().getMessage());
throw new RpcException(response.getError());
} else {
return response.getResult();
}
}
return null;
}
Aggregations