Search in sources :

Example 1 with RpcInvoker

use of com.jim.framework.rpc.common.RpcInvoker in project jim-framework by jiangmin168168.

the class RpcHystrixCommand method run.

@Override
protected Object run() {
    RpcRequest request = new RpcRequest();
    request.setRequestId(UUID.randomUUID().toString());
    request.setClassName(method.getDeclaringClass().getName());
    request.setMethodName(method.getName());
    request.setParameterTypes(method.getParameterTypes());
    request.setParameters(this.params);
    if (this.rpcReference != null) {
        request.setMaxExecutesCount(this.rpcReference.maxExecutesCount());
    }
    request.setContextParameters(RpcContext.getContext().getContextParameters());
    RpcClientInvoker invoker = RpcClientInvokerManager.getInstance(this.referenceConfig).getInvoker();
    invoker.setRpcRequest(request);
    RpcInvoker rpcInvoker = invoker.buildInvokerChain(invoker);
    ResponseFuture response = (ResponseFuture) rpcInvoker.invoke(invoker.buildRpcInvocation(request));
    if (this.rpcReference.isSync()) {
        return response.get();
    } else {
        RpcContext.getContext().setResponseFuture(response);
        return null;
    }
}
Also used : RpcClientInvoker(com.jim.framework.rpc.client.RpcClientInvoker) RpcRequest(com.jim.framework.rpc.common.RpcRequest) RpcInvoker(com.jim.framework.rpc.common.RpcInvoker)

Aggregations

RpcClientInvoker (com.jim.framework.rpc.client.RpcClientInvoker)1 RpcInvoker (com.jim.framework.rpc.common.RpcInvoker)1 RpcRequest (com.jim.framework.rpc.common.RpcRequest)1