Joh*_*ria 4 apache httpclient apache-httpclient-4.x apache-httpasyncclient
通过典型HttpAsyncClients示例:
public class AsyncClientHttpExchange {
public static void main(final String[] args) throws Exception {
CloseableHttpAsyncClient httpclient = HttpAsyncClients.createDefault();
try {
httpclient.start();
HttpGet request = new HttpGet("http://httpbin.org/get");
Future<HttpResponse> future = httpclient.execute(request, null);
HttpResponse response = future.get();
System.out.println("Response: " + response.getStatusLine());
System.out.println("Shutting down");
} finally {
httpclient.close();
}
System.out.println("Done");
}
}
Run Code Online (Sandbox Code Playgroud)
如果没有响应,设置重试次数的方法是什么?我可以看到5.
随着httpClientBuilder存在setRetryHandler:
httpClientBuilder.setRetryHandler(new MyRequestRetryHandler(_maxRetryCount));
Run Code Online (Sandbox Code Playgroud)
有什么办法HttpAsyncClients?
| 归档时间: |
|
| 查看次数: |
910 次 |
| 最近记录: |