예제 #1
0
  private void processRpcRequest(final RpcRequest req) {
    try {
      rpcHandler.receive(
          reverseClient,
          req.message,
          new RpcResponseCallback() {
            @Override
            public void onSuccess(byte[] response) {
              respond(new RpcResponse(req.requestId, response));
            }

            @Override
            public void onFailure(Throwable e) {
              respond(new RpcFailure(req.requestId, Throwables.getStackTraceAsString(e)));
            }
          });
    } catch (Exception e) {
      logger.error("Error while invoking RpcHandler#receive() on RPC id " + req.requestId, e);
      respond(new RpcFailure(req.requestId, Throwables.getStackTraceAsString(e)));
    }
  }
예제 #2
0
 /**
  * Receives an RPC message that does not expect a reply. The default implementation will call
  * "{@link receive(TransportClient, byte[], RpcResponseCallback)}" and log a warning if any of the
  * callback methods are called.
  *
  * @param client A channel client which enables the handler to make requests back to the sender of
  *     this RPC. This will always be the exact same object for a particular channel.
  * @param message The serialized bytes of the RPC.
  */
 public void receive(TransportClient client, ByteBuffer message) {
   receive(client, message, ONE_WAY_CALLBACK);
 }