Example usage for org.springframework.web.client AsyncRestTemplate getAsyncRequestFactory

List of usage examples for org.springframework.web.client AsyncRestTemplate getAsyncRequestFactory

Introduction

In this page you can find the example usage for org.springframework.web.client AsyncRestTemplate getAsyncRequestFactory.

Prototype

@Override
    public org.springframework.http.client.AsyncClientHttpRequestFactory getAsyncRequestFactory() 

Source Link

Usage

From source file:org.springframework.boot.actuate.metrics.ambari.restclient.AsyncAmbariMetricsCollectorRestClient.java

private AsyncRestTemplate createTimelineClient() {

    MappingJackson2HttpMessageConverter mc = new MappingJackson2HttpMessageConverter();
    JaxbAnnotationModule module = new JaxbAnnotationModule();
    mc.getObjectMapper().registerModule(module);
    mc.getObjectMapper().setSerializationInclusion(Include.NON_NULL);

    AsyncRestTemplate restTemplate = new AsyncRestTemplate();
    restTemplate.getMessageConverters().clear();
    restTemplate.getMessageConverters().add(mc);

    SimpleClientHttpRequestFactory requestFactory = (SimpleClientHttpRequestFactory) restTemplate
            .getAsyncRequestFactory();/*from w w  w. j  a v a  2 s .c  o  m*/
    requestFactory.setReadTimeout(5000);
    requestFactory.setConnectTimeout(5000);

    return restTemplate;
}