使用 HttpAsyncClients 设置重试次数

set number of retries with HttpAsyncClients

以典型的 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.

httpClientBuildersetRetryHandler :

httpClientBuilder.setRetryHandler(new MyRequestRetryHandler(_maxRetryCount));

HttpAsyncClients有什么方法?

HttpAsyncClient 4.x 不支持自动请求重新执行。此功能计划用于 HttpAsyncClient 5.0