Ejemplo n.º 1
0
  private Response forwardToBlockingService(Request rpcRequest, BlockingService blockingService)
      throws RpcException {
    // Get matching method
    MethodDescriptor method = getMethod(rpcRequest, blockingService.getDescriptorForType());

    // Create request for method
    Message request = getRequestProto(rpcRequest, blockingService.getRequestPrototype(method));

    // Call method
    SocketRpcController socketController = new SocketRpcController();
    try {
      Message response = blockingService.callBlockingMethod(method, socketController, request);
      return createRpcResponse(response, true, socketController);
    } catch (ServiceException e) {
      throw new RpcException(ErrorReason.RPC_FAILED, e.getMessage(), e);
    } catch (RuntimeException e) {
      throw new RpcException(
          ErrorReason.RPC_ERROR, "Error running method " + method.getFullName(), e);
    }
  }
Ejemplo n.º 2
0
 @NotNull
 @Override
 public Message getRequestPrototype(@NotNull Descriptors.MethodDescriptor method) {
   return service.getRequestPrototype(method);
 }