in benchmark/src/main/java/org/apache/rocketmq/benchmarks/remoting/AbstractBenchmark.java [32:55]
public static void main(String[] args) throws InterruptedException {
RemotingServer server = RemotingBootstrapFactory.createRemotingServer(new RemotingServerConfig());
server.registerRequestProcessor((short) 1, (channel, request) -> {
RemotingCommand response = server.commandFactory().createResponse(request);
response.payload("zhouxinyu".getBytes());
System.out.println(new String(request.payload()));
return response;
});
server.start();
RemotingClient client = RemotingBootstrapFactory.createRemotingClient(new RemotingClientConfig());
client.start();
RemotingCommand request = client.commandFactory().createRequest();
request.cmdCode((short) 1);
request.cmdVersion((short) 1);
request.payload("hello".getBytes());
RemotingCommand response = client.invoke("127.0.0.1:8888", request, 3000);
System.out.println(new String(response.payload()));
client.stop();
server.stop();
}