RpcInvocation inv = new RpcInvocation(invocation);
//拿不到client端export 的service path.约定为interface的名称.
inv.setAttachment(Constants.PATH_KEY, getInterface().getName());
inv.setAttachment(RpcConstants.CALLBACK_SERVICE_KEY, serviceKey);
ExchangeClient currentClient = new HeaderExchangeClient(new ChannelWrapper(this.channel));
try {
if (getUrl().getMethodParameter(invocation.getMethodName(), Constants.ASYNC_KEY, false)) { // 不可靠异步
currentClient.send(inv,getUrl().getMethodParameter(invocation.getMethodName(), Constants.SENT_KEY, false));
return new RpcResult();
}
int timeout = getUrl().getMethodParameter(invocation.getMethodName(),
Constants.TIMEOUT_KEY, Constants.DEFAULT_TIMEOUT);
if (timeout > 0) {
return (Result) currentClient.request(inv, timeout).get();
} else {
return (Result) currentClient.request(inv).get();
}
} catch (RpcException e) {
throw e;
} catch (TimeoutException e) {
throw new RpcException(RpcException.TIMEOUT_EXCEPTION, e.getMessage(), e);