使用典型的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
的方式是什么?
答案 0 :(得分:9)
HttpAsyncClient 4.x不支持自动请求重新执行。此功能计划用于HttpAsyncClient 5.0