Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

set number of retries with HttpAsyncClients

With the typical HttpAsyncClients example:

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");
    }
}

What is the way to set the number of retries in case there is no response?. I can see 5.

With httpClientBuilder there is the setRetryHandler :

httpClientBuilder.setRetryHandler(new MyRequestRetryHandler(_maxRetryCount));

What is the way with HttpAsyncClients?

like image 792
John Fadria Avatar asked Jan 05 '23 10:01

John Fadria


1 Answers

HttpAsyncClient 4.x does not support automatic request re-execution. This feature is planned for HttpAsyncClient 5.0

like image 110
ok2c Avatar answered Jan 07 '23 00:01

ok2c