List of usage examples for org.springframework.http.client HttpComponentsAsyncClientHttpRequestFactory setAsyncClient
public void setAsyncClient(HttpAsyncClient asyncClient)
From source file:io.getlime.push.service.fcm.FcmClient.java
/** * Set information about proxy.// w w w. j a va 2s .co m * @param host Proxy host URL. * @param port Proxy port. * @param username Proxy username, use 'null' for proxy without authentication. * @param password Proxy user password, ignored in case username is 'null' */ public void setProxy(String host, int port, String username, String password) { HttpAsyncClientBuilder clientBuilder = HttpAsyncClientBuilder.create(); clientBuilder.useSystemProperties(); clientBuilder.setProxy(new HttpHost(host, port)); if (username != null) { CredentialsProvider credsProvider = new BasicCredentialsProvider(); UsernamePasswordCredentials user = new UsernamePasswordCredentials(username, password); credsProvider.setCredentials(new AuthScope(host, port), user); clientBuilder.setDefaultCredentialsProvider(credsProvider); clientBuilder.setProxyAuthenticationStrategy(new ProxyAuthenticationStrategy()); } CloseableHttpAsyncClient client = clientBuilder.build(); HttpComponentsAsyncClientHttpRequestFactory factory = new HttpComponentsAsyncClientHttpRequestFactory(); factory.setAsyncClient(client); restTemplate.setAsyncRequestFactory(factory); }