com.alipay.remoting.rpc.protocol.AsyncUserProcessor Java Examples
The following examples show how to use
com.alipay.remoting.rpc.protocol.AsyncUserProcessor.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BoltRpcServer.java From sofa-jraft with Apache License 2.0 | 4 votes |
@Override public void registerProcessor(final RpcProcessor processor) { this.rpcServer.registerUserProcessor(new AsyncUserProcessor<Object>() { @SuppressWarnings("unchecked") @Override public void handleRequest(final BizContext bizCtx, final AsyncContext asyncCtx, final Object request) { final RpcContext rpcCtx = new RpcContext() { @Override public void sendResponse(final Object responseObj) { asyncCtx.sendResponse(responseObj); } @Override public Connection getConnection() { com.alipay.remoting.Connection conn = bizCtx.getConnection(); if (conn == null) { return null; } return new BoltConnection(conn); } @Override public String getRemoteAddress() { return bizCtx.getRemoteAddress(); } }; processor.handleRequest(rpcCtx, request); } @Override public String interest() { return processor.interest(); } @Override public ExecutorSelector getExecutorSelector() { final RpcProcessor.ExecutorSelector realSelector = processor.executorSelector(); if (realSelector == null) { return null; } return realSelector::select; } @Override public Executor getExecutor() { return processor.executor(); } }); }