【发布时间】:2017-07-22 03:17:14
【问题描述】:
以典型的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");
}
}
在没有响应的情况下设置重试次数的方法是什么?我可以看到 5。
httpClientBuilder 有 setRetryHandler:
httpClientBuilder.setRetryHandler(new MyRequestRetryHandler(_maxRetryCount));
HttpAsyncClients是怎么回事?
【问题讨论】:
标签: java apache-httpclient-4.x apache-httpcomponents apache-httpasyncclient