Changing a work project's version to java 17 resulted in the need to increase the spring-cloud-starter-openfeign to 3.0.6 (part of the 2020.0.0 Spring Cloud release train). Since Spring Cloud Netflix Ribbon has been deprecated and is not included in the 2020.0.0 release train, I have to make some changes in my project and switch to using Spring Cloud LoadBalancer.
After reading some articles I got the following understanding: Feign was using Ribbon as a LoadBalancer. Ribbon was configured in a properties file with different lists of hosts for all the applications clients.
My questions are:
You can find comprehensive documentation of Spring Cloud LoadBalancer, with all the details on how to set it up here. You can use it with Service Registry or, if you want to pass the list of hosts manually in properties, you can use SimpleDiscoveryClient
You can also find a sample that uses Spring Cloud OpenFeign with Spring Cloud LoadBalancer here - the spring-cloud-starter-loadbalancer
dependency is not in the pom, but gets included transitively via spring-cloud-starter-netflix-eureka-client
. For more information about switching from Spring Cloud Netflix - based stack to the currently supported Spring Cloud stack, you can also watch this presentation recording.
Spring Cloud OpenFeign 3.0.5
works with Spring Cloud LoadBalancer 3.0.4
, however, manually setting library versions for Spring Cloud is discouraged in general. You should use dependency management instead. You can find the setup at Spring Cloud projects landing page. Also, the easiest way to generate a correct build file for Spring Cloud Projects is to use start.spring.io.