[
https://issues.apache.org/jira/browse/HTTPASYNC-129?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16270137#comment-16270137
]
Muzeeb commented on HTTPASYNC-129:
----------------------------------
Thanks Gary. I have analyzed the code and found that the issue was related to
httpClient object closing.
Now it is working as expected both in linux and windows. appreciate for your
patience. Closing this ticket now.
Here is the optimized code.
public void invokePostAPIMethodsAsychronously(List<ClientAPI> clientAPIs)
throws Exception {
logger.debug("Entering invokePostAPIMethodsAsychronously()");
RequestConfig requestConfig =
RequestConfig.custom().setSocketTimeout(3000).setConnectTimeout(3000).build();
CloseableHttpAsyncClient httpClient = HttpAsyncClients.custom()
.setDefaultRequestConfig(requestConfig)
.setMaxConnPerRoute(1000)
.setMaxConnTotal(1000)
.build();
try {
httpClient.start();
final CountDownLatch latch = new
CountDownLatch(clientAPIs.size());
clientAPIs.parallelStream().forEach( clientAPI -> {
HttpPost postRequest = new
HttpPost(clientAPI.getEndPoint());
logger.info("The post API call is
"+clientAPI.getEndPoint());
if(clientAPI.getBasicAuthUserName() !=null &&
clientAPI.getBasciAuthPassword() !=null) {
Header authHeader =new
BasicHeader(Constants.JSON_REQUEST_HEADER_AUTHORIZATION_STRING,
Constants.JSON_REQUEST_HEADER_BASIC_STRING+
getAuthString(clientAPI.getBasicAuthUserName(),clientAPI.getBasciAuthPassword()));
postRequest.addHeader(authHeader);
}
if(clientAPI.getHeaderParamKey() !=null &&
clientAPI.getHeaderParamValue() !=null) {
Header customHeader =new
BasicHeader(clientAPI.getHeaderParamKey(),clientAPI.getHeaderParamValue());
postRequest.addHeader(customHeader);
}
StringEntity requestEntity = new
StringEntity(clientAPI.getJsonRequest(), ContentType.APPLICATION_JSON);
postRequest.setEntity(requestEntity);
httpClient.execute(postRequest, new
FutureCallback<HttpResponse>() {
public void completed(final HttpResponse response) {
latch.countDown();
logger.info(postRequest.getRequestLine() + "->" +
response.getStatusLine());
}
public void failed(final Exception ex) {
latch.countDown();
logger.info(postRequest.getRequestLine() + "->" + ex);
}
public void cancelled() {
latch.countDown();
logger.info(postRequest.getRequestLine() + "
cancelled");
}
});
});
latch.await();
} catch(Exception e){
logger.error(e.getMessage());
throw e;
} finally {
httpClient.close();
}
logger.debug("Exiting invokePostAPIMethodsAsychronously()");
}
> CloseableHttpAsyncClient is not working in Oracle Enterprise Linux Server
> -------------------------------------------------------------------------
>
> Key: HTTPASYNC-129
> URL: https://issues.apache.org/jira/browse/HTTPASYNC-129
> Project: HttpComponents HttpAsyncClient
> Issue Type: Bug
> Affects Versions: 4.1.3
> Environment: Oracle Enterprise Linux Server
> Reporter: Muzeeb
>
> Hi Apache Team,
> It appears that CloseableHttpAsyncClient object is not invoking any rest API
> calls in oracle linux server. same application is working as expected in
> windows server.
> Please find our application details below.
> Application Type: Spring Boot Microservice
> JDK: 1.8.
> HttpAsyncClient: 4.1.3
> Please let me know if you need any details to troubleshoot this issue.
> Regards
> Muzeeb
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]