We're moving away from the spring-cloud Netflix OSS ecosystem one step at a time. Currently we're implementing spring-cloud-loadbalancer and removing Ribbon. However we used to have a lot of static services in our integration tests, now with the move from ribbon towards spring-cloud-loadbalancer those properties are not being picked up any longer. i.e.:
foo-service.ribbon.NIWSServerListClassName=com.netflix.loadbalancer.ConfigurationBasedServerList
foo-service.ribbon.listOfServers=localhost:9876
We've migrated towards using spring-cloud-loadbalancer in the following way
First we annotated our Webclient.Builder with @LoadBalanced like this
@Bean
@LoadBalanced
fun webClientBuilder() = WebClient.builder()
And then we've added the @LoadBalancerClient annotation on the client classes like this
@LoadBalancerClient(name = "foo-service", configuration = [FooServiceConfiguration::class])
class FooServiceClient(private val basicAuthWebClient: WebClient)
This results in our tests failing with an UnknownHostException for foo-service.
Now My question is how do we configure this static server list in the new spring-cloud-loadbalancer?
Based on @spencergibb's comment, I guess something like this should work:
spring:
cloud:
discovery:
client:
simple:
instances:
foo-service:
- instanceId: foo1
serviceId: foo-service
host: localhost
port: 9876```
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With