Spring AsyncResttemplate HTTPs (SSL) service call

972 Views Asked by At

I am using Spring asyncresttempate to call multiple services simultaneously. Those services are exposed via SSL. could you please let me know how to use the SSL certificate and AsyncResttemplate to call the services asynchronously? We can use RestTemplate with HttpConnectionFactory, how to do the same for AsyncRestTemplate.

I am using Spring 4.3, JDK 8.

1

There are 1 best solutions below

0
On

You can use AsyncClientHttpRequestFactory:

        CloseableHttpAsyncClient httpclient = HttpAsyncClients.custom()
              .setSSLHostnameVerifier(SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER)
                  .setSSLContext(getSSLCOntext(keyStore)).build();

        AsyncClientHttpRequestFactory reqFactory =
              new HttpComponentsAsyncClientHttpRequestFactory(httpclient);
        AsyncRestTemplate restTemplate = new AsyncRestTemplate(reqFactory);