Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save marciorodrigues87/68da40032b3cf0c0e42447da83abf0fb to your computer and use it in GitHub Desktop.
Save marciorodrigues87/68da40032b3cf0c0e42447da83abf0fb to your computer and use it in GitHub Desktop.
RestTemplateConfigStepEight.java
final RequestConfig requestConfig = RequestConfig.custom()
.setConnectionRequestTimeout(100)
.setConnectTimeout(500)
.setSocketTimeout(1000)
.build();
final HttpClient httpClient = HttpClients.custom()
.setMaxConnPerRoute(100)
.setMaxConnTotal(1000)
.setConnectionTimeToLive(30, MINUTES)
.setRetryHandler((IOException exception, int executionCount, HttpContext context) -> {
return executionCount <= 3;
})
.setServiceUnavailableRetryStrategy(new DefaultServiceUnavailableRetryStrategy(3, 1))
.setDefaultRequestConfig(requestConfig)
.setUserAgent("Aplicacao-VivaReal-v1.0.2") // <--
.build();
final RestTemplate restTemplate = new RestTemplate(new HttpComponentsClientHttpRequestFactory(httpClient));
restTemplate.setInterceptors(asList(new BasicAuthorizationInterceptor("user", "password")));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment