### Question:
NettyClient extends NettyRemotingAbstract implements IClient { @Override public Message call(String addr, Message req, long timeOut) throws Exception { final RemotingCommand request = RemotingCommand.createRequestCommand(req); long timeoutMillis = timeOut; final Channel channel = this.getAndCreateChannel(addr); RemotingCommand response = this.invokeSyncImpl(channel, request, timeoutMillis); return response.getMessage(); } NettyClient(IServiceDiscovery serviceDiscovery); void startScanResponseTableSchedule(); @Override Message call(String addr, Message req, long timeOut); @Override Message call(Message req, long timeoutMillis, String sendType); static SocketAddress string2SocketAddress(final String addr); void invokeOnewayImpl(final Channel channel, final RemotingCommand request, final long timeoutMillis); ResponseFuture invokeAsyncImpl(final Channel channel, final RemotingCommand request, final long timeoutMillis,
                                          final InvokeCallback invokeCallback); RemotingCommand invokeSyncImpl(final Channel channel, final RemotingCommand request, final long timeoutMillis); @Override void putNettyEvent(final NettyEvent event); @Override IServiceDiscovery getServiceDiscovery(); @Override void close();  }### Answer:
@Test public void testSendMsg() throws Exception { Message req = new Message("Arith", "Echo"); req.setVersion((byte) 0); req.setMessageType(MessageType.Request); req.setHeartbeat(false); req.setOneway(false); req.setCompressType(CompressType.None); req.setSerializeType(SerializeType.SerializeNone); req.setSeq(123); req.metadata.put("test", "1234"); req.payload = "world".getBytes("UTF-8"); NettyClient client = new NettyClient(null); Message res = client.call("192.168.31.82:8997", req, 1000); System.out.println(new String(res.payload)); }
@Test public void testGolangServiceFinder() throws Exception { Message req = new Message("Arith", "Echo"); req.setVersion((byte) 0); req.setMessageType(MessageType.Request); req.setHeartbeat(false); req.setOneway(false); req.setCompressType(CompressType.None); req.setSerializeType(SerializeType.SerializeNone); req.setSeq(123); req.metadata.put("test", "1234"); req.payload = "world".getBytes("UTF-8"); ZkServiceDiscovery serviceDiscovery = new ZkServiceDiscovery("/youpin/services/", "Arith"); NettyClient client = new NettyClient(serviceDiscovery); Message res = client.call(req, 2000, Constants.SYNC_KEY); System.out.println(new String(res.payload)); }
@Test public void testLoopSendMsg() throws Exception { Message req = new Message("Arith", "Echo"); req.setVersion((byte) 0); req.setMessageType(MessageType.Request); req.setHeartbeat(false); req.setOneway(false); req.setCompressType(CompressType.None); req.setSerializeType(SerializeType.SerializeNone); req.setSeq(123); req.metadata.put("test", "1234"); req.payload = "world".getBytes("UTF-8"); NettyClient client = new NettyClient(null); IntStream.range(0, 100).forEach(it -> { Message res = null; try { res = client.call("10.231.72.75:8976", req, 1000); } catch (Exception e) { e.printStackTrace(); } System.out.println(new String(res.payload)); }); }