Example usage for org.springframework.boot.web.client RestTemplateBuilder setConnectTimeout

List of usage examples for org.springframework.boot.web.client RestTemplateBuilder setConnectTimeout

Introduction

In this page you can find the example usage for org.springframework.boot.web.client RestTemplateBuilder setConnectTimeout.

Prototype

public RestTemplateBuilder setConnectTimeout(Duration connectTimeout) 

Source Link

Document

Sets the connection timeout on the underlying ClientHttpRequestFactory .

Usage

From source file:com.netflix.genie.web.configs.GenieApiAutoConfiguration.java

/**
 * Get RestTemplate for calling between Genie nodes.
 *
 * @param httpProperties      The properties related to Genie's HTTP client configuration
 * @param restTemplateBuilder The Spring REST template builder to use
 * @return The rest template to use/*from  w w  w .  java  2s . co m*/
 */
@Bean
@ConditionalOnMissingBean(name = "genieRestTemplate")
public RestTemplate genieRestTemplate(final HttpProperties httpProperties,
        final RestTemplateBuilder restTemplateBuilder) {
    return restTemplateBuilder
            .setConnectTimeout(Duration.of(httpProperties.getConnect().getTimeout(), ChronoUnit.MILLIS))
            .setReadTimeout(Duration.of(httpProperties.getRead().getTimeout(), ChronoUnit.MILLIS)).build();
}