哪个HTTPClient可用于长时间运行的进程

时间:2022-06-24 21:04:14

I have a requirement where I would need to call a servlet end point. The servlet does the huge task. It might take about hours to do task.

我有一个要求,我需要调用servlet端点。 servlet完成了巨大的任务。完成任务可能需要几个小时。

Keeping all these, I need to build a http client which keeps connection and call this end point. I am not interested in the response. It should just call the endpoint and forget. Which client should i use ?

保持所有这些,我需要构建一个http客户端,它保持连接并调用此终点。我对回复不感兴趣。它应该只是调用端点而忘记。我应该使用哪个客户?

I tried with apache http client

我试过apache http客户端

CloseableHttpAsyncClient httpclient = HttpAsyncClients.createDefault();
httpclient.start();
HttpGet request = new HttpGet(URL);`
Future<HttpResponse> future = httpclient.execute(request,null);

Does this call the end point of the servlet, because I don't see any logs of the servlet endpoint.

这是否调用servlet的终点,因为我没有看到servlet端点的任何日志。

HttpResponse response = future.get(); 

Is this line required ? As I don't need to capture response.

这条线是否需要?因为我不需要捕获响应。

1 个解决方案

#1


0  

No, it is not needed. The line:

不,不需要。这条线:

HttpResponse response = future.get(); 

blocks your thread until the there is a HTTP response or connection breaks. Check out Future.get() javadoc

阻止你的线程,直到有HTTP响应或连接断开。查看Future.get()javadoc

#1


0  

No, it is not needed. The line:

不,不需要。这条线:

HttpResponse response = future.get(); 

blocks your thread until the there is a HTTP response or connection breaks. Check out Future.get() javadoc

阻止你的线程,直到有HTTP响应或连接断开。查看Future.get()javadoc