### Question:
TaskCallbackService { public void sendResult(int taskInstanceId, Command command){ NettyRemoteChannel nettyRemoteChannel = getRemoteChannel(taskInstanceId); nettyRemoteChannel.writeAndFlush(command).addListener(new ChannelFutureListener(){ @Override public void operationComplete(ChannelFuture future) throws Exception { if(future.isSuccess()){ remove(taskInstanceId); return; } } }); } TaskCallbackService(); void addRemoteChannel(int taskInstanceId, NettyRemoteChannel channel); int pause(int ntries); void remove(int taskInstanceId); void sendAck(int taskInstanceId, Command command); void sendResult(int taskInstanceId, Command command);  }### Answer:
@Test public void testSendResult() throws Exception{ final NettyServerConfig serverConfig = new NettyServerConfig(); serverConfig.setListenPort(30000); NettyRemotingServer nettyRemotingServer = new NettyRemotingServer(serverConfig); nettyRemotingServer.registerProcessor(CommandType.TASK_EXECUTE_RESPONSE, taskResponseProcessor); nettyRemotingServer.start(); final NettyClientConfig clientConfig = new NettyClientConfig(); NettyRemotingClient nettyRemotingClient = new NettyRemotingClient(clientConfig); Channel channel = nettyRemotingClient.getChannel(Host.of("localhost:30000")); taskCallbackService.addRemoteChannel(1, new NettyRemoteChannel(channel, 1)); TaskExecuteResponseCommand responseCommand = new TaskExecuteResponseCommand(); responseCommand.setTaskInstanceId(1); responseCommand.setEndTime(new Date()); taskCallbackService.sendResult(1, responseCommand.convert2Command()); Thread.sleep(5000); Stopper.stop(); Thread.sleep(5000); nettyRemotingServer.close(); nettyRemotingClient.close(); }