<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpasyncclient</artifactId>
<version>4.1.1</version>
</dependency>
从pom依赖可以发现,底层依赖于Netty的NIO异步事件通知模式来实现非阻塞!
<dependency>
<groupId>org.asynchttpclient</groupId>
<artifactId>async-http-client</artifactId>
<version>2.0.32</version>
</dependency>
- com.onlyone.AsyncHttpClientTest#asyncHttpClient_prepareGet
提供最基本的prepareGet方法,并返回结果
- com.onlyone.AsyncHttpClientTest#asyncHttpClient_executeRequest_withAsyncHandler
执行request请求,并支持传入 org.asynchttpclient.AsyncHandler 自定义处理结果
- com.onlyone.AsyncHttpClientTest#asyncHttpClient_executeRequest_withAsyncHandler_v1
服务端有响应时即可立即读取,不用等到所有内容全响应过来。适用于数据量比较大的网络传输
- com.onlyone.AsyncTimeoutTest#asyncHttpClient_prepareGet
超时测试