zipkin and LoadBalanced
hello。
I want to customize the load balancing algorithm, the code is as follows service1===>service2
service1 main code ==================== @SpringBootApplication public class WebDemoApplication { public static void main(String[] args) { run(WebDemoApplication.class, args); }
@Bean @LoadBalanced public RestTemplate getRestTemplate() { return new RestTemplate(); }
@Bean
public IRule getLoadBalancedRule() {
return new RandomRule();
}
}
service1 maven ====================
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-sleuth-zipkin</artifactId>
</dependency>
But every time service1 accesses the servicer2 interface, the first request is ok, the second request fails, and the following error is reported.
**: Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.RuntimeException: com.netflix.client.ClientException: Load balancer does not have available server for client: BUSINESS-SERVICE-DEMO2] with root cause_**_
I think maybe it’s a problem with this object because
ZoneAwareLoadBalancer
spring.zipkin.base-url Created one ZoneAwareLoadBalancer
destroyed ZoneAwareLoadBalancer for BUSINESS-SERVICE-DEMO2
I am very sorry, this is totally my mistake, I did not read the ribbon related documents carefully.