Search in sources :

Example 1 with RpcRequest

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

the class AbstractHeartbeatHandler method sendPing.

protected void sendPing(ChannelHandlerContext channelHandlerContext) {
    RpcMessage message = new RpcMessage();
    RpcRequest rpcRequest = new RpcRequest();
    rpcRequest.setRequestId("ping");
    RpcMessageHeader messageHeader = new RpcMessageHeader();
    messageHeader.setLength(1);
    messageHeader.setType(Constants.MESSAGE_TYPE_HEARTBEAT_PING);
    message.setMessageHeader(messageHeader);
    message.setMessageBody(rpcRequest);
    channelHandlerContext.writeAndFlush(message);
    logger.info("ping:{}", message.getMessageBody());
}
Also used : RpcMessageHeader(com.jim.framework.rpc.protocol.RpcMessageHeader) RpcRequest(com.jim.framework.rpc.common.RpcRequest) RpcMessage(com.jim.framework.rpc.protocol.RpcMessage)

Example 2 with RpcRequest

use of com.jim.framework.rpc.common.RpcRequest 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

RpcRequest (com.jim.framework.rpc.common.RpcRequest)2 RpcClientInvoker (com.jim.framework.rpc.client.RpcClientInvoker)1 RpcInvoker (com.jim.framework.rpc.common.RpcInvoker)1 RpcMessage (com.jim.framework.rpc.protocol.RpcMessage)1 RpcMessageHeader (com.jim.framework.rpc.protocol.RpcMessageHeader)1