I'm struggling to switch from Ribbon to Spring Cloud Loadbalancer after upgrading spring cloud versions. Setting up the SimpleDiscoveryClient with Feign was easy. But the simplediscovery client is 'too simple'. I want to add at least a healthcheck so it doesn't use an instance that is potentially down & preferably also a retry mechanism. I've read the docs over & over but cannot find an easy way to set this up.
https://docs.spring.io/spring-cloud-commons/docs/current/reference/html/#instance-health-check-for-loadbalancer I found this example custom config for the health check, but it doesn't work.
public class CustomLoadBalancerConfiguration {
@Bean
public ServiceInstanceListSupplier discoveryClientServiceInstanceListSupplier(
ConfigurableApplicationContext context) {
return ServiceInstanceListSupplier.builder()
.withDiscoveryClient()
.withHealthChecks()
.build(context);
}
}
if I run it as is, it throws the following missing bean error: Method discoveryClientServiceInstanceListSupplier in XXX.CustomLoadBalancerConfig required a bean of type 'org.springframework.web.client.RestTemplate' that could not be found.
Can anyone give me some pointers on how to get this working or how I can replicate the ribbon behavior?