作者:青春梦敲门砖 | 来源:互联网 | 2023-02-10 11:36
通过典型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 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
?
1> ok2c..:
HttpAsyncClient 4.x不支持自动请求重新执行.此功能计划用于HttpAsyncClient 5.0