I have a spring boot application that is running on version 2.1.7. I am trying to implement a custom rest template using Rest Template Builder in order to set connection and read timeouts. I’ve learned I need to use Rest Template Builder since I am running on 2.1.7. The code for my custom rest template is shown below. I need assistance with calling this rest template in other areas of my code since this rest template is going to be utilized by various components of my application but I need help doing so. Any advice on this would be greatly appreciated. Thanks!
public abstract class CustomRestTemplate implements RestTemplateCustomizer {
public void customize(RestTemplate restTemplate, Integer connectTimeout, Integer readTimeout) {
restTemplate.setRequestFactory(new SimpleClientHttpRequestFactory());
SimpleClientHttpRequestFactory template = (SimpleClientHttpRequestFactory) restTemplate.getRequestFactory();
template.setConnectTimeout(connectTimeout);
template.setReadTimeout(readTimeout);
}
}