@Override
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e)
throws Exception {
RpcResponse rpcResponse = (RpcResponse) e.getMessage();
ProtoCallFuture callback = requests.remove(rpcResponse.getId());
if (callback == null) {
LOG.warn("Dangling rpc call");
} else {
if (rpcResponse.hasErrorMessage()) {
callback.setFailed(rpcResponse.getErrorMessage(),
new ServiceException(getErrorMessage(rpcResponse.getErrorMessage())));
throw new RemoteException(
getErrorMessage(rpcResponse.getErrorMessage()));
} else {
Message responseMessage;
if (!rpcResponse.hasResponseMessage()) {
responseMessage = null;
} else {
responseMessage =
callback.returnType.newBuilderForType().
mergeFrom(rpcResponse.getResponseMessage()).build();
}
callback.setResponse(responseMessage);
}
}