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);
}
}
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;
}
Aggregations