Search in sources :

Example 1 with ResponseFuture

use of com.jim.framework.rpc.proxy.ResponseFuture in project jim-framework by jiangmin168168.

the class RpcClientInvoker method channelRead0.

@Override
public void channelRead0(ChannelHandlerContext ctx, RpcMessage message) {
    RpcResponse response = (RpcResponse) message.getMessageBody();
    String requestId = response.getRequestId();
    ResponseFuture responseFuture = pendingRPC.get(requestId);
    if (responseFuture != null) {
        pendingRPC.remove(requestId);
        responseFuture.done(response);
    }
}
Also used : ResponseFuture(com.jim.framework.rpc.proxy.ResponseFuture)

Example 2 with ResponseFuture

use of com.jim.framework.rpc.proxy.ResponseFuture in project jim-framework by jiangmin168168.

the class RpcClientInvoker method invoke.

@Override
public ResponseFuture invoke(RpcInvocation invocation) {
    RpcRequest request = this.getRpcRequest();
    ResponseFuture responseFuture = new ResponseFuture(request);
    pendingRPC.put(request.getRequestId(), responseFuture);
    RpcMessage message = new RpcMessage();
    byte[] data = ProtoStuffSerializeUtil.serialize(request);
    RpcMessageHeader messageHeader = new RpcMessageHeader();
    messageHeader.setLength(data.length);
    message.setMessageHeader(messageHeader);
    message.setMessageBody(request);
    channel.writeAndFlush(message);
    return responseFuture;
}
Also used : RpcMessageHeader(com.jim.framework.rpc.protocol.RpcMessageHeader) ResponseFuture(com.jim.framework.rpc.proxy.ResponseFuture) RpcMessage(com.jim.framework.rpc.protocol.RpcMessage)

Aggregations

ResponseFuture (com.jim.framework.rpc.proxy.ResponseFuture)2 RpcMessage (com.jim.framework.rpc.protocol.RpcMessage)1 RpcMessageHeader (com.jim.framework.rpc.protocol.RpcMessageHeader)1