/**
* Handle the blocking RPC request by forwarding it to the correct
* service/method.
*
* @throws RpcException If there was some error executing the RPC.
*/
public SocketRpcProtos.Response doBlockingRpc(
SocketRpcProtos.Request rpcRequest) throws RpcException {
// Get the service, first try BlockingService
BlockingService blockingService = blockingServiceMap.get(
rpcRequest.getServiceName());
if (blockingService != null) {
return forwardToBlockingService(rpcRequest, blockingService);
}
// Now try Service
Service service = serviceMap.get(rpcRequest.getServiceName());
if (service == null) {
throw new RpcException(ErrorReason.SERVICE_NOT_FOUND,
"Could not find service: " + rpcRequest.getServiceName(), null);
}
// Call service using an instant callback
Callback<Message> callback = new Callback<Message>();
SocketRpcController socketController = new SocketRpcController();
forwardToService(rpcRequest, callback, service, socketController);
// Build and return response (callback invocation is optional)
return createRpcResponse(callback.response, callback.invoked,
socketController);
}
RpcForwarder.java 文件源码
java
阅读 25
收藏 0
点赞 0
评论 0
项目:protobuf-socket-rpc
作者:
评论列表
文章目录