For the timeouts I have a possible solution to create a different load balanced restTemplate for each API called:
@Bean
@LoadBalanced
public RestTemplate restTemplate(RestTemplateBuilder builder, Environment env){
builder.setReadTimeout(env.getProperty(SERVICE_NAME + ".ribbon.ReadTimeout", Duration.class, Duration.of(3L, ChronoUnit.SECONDS)));
//builder.additionalInterceptors(...);
//builder.errorHandler(...)
return builder.build();
}
For the discovery settings, more exactly the static list of addresses I made a class that implements org.springframework.cloud.client.discovery.DiscoveryClient, but how should I deal with the retry settings, more exactly with MaxAutoRetriesNextServer ?
And is this the best approach to create a different restTemplate for each API called?