spring-cloud-sleuth icon indicating copy to clipboard operation
spring-cloud-sleuth copied to clipboard

zipkin and LoadBalanced

Open labidc opened this issue 7 years ago • 1 comments

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 ==================== org.springframework.cloud spring-cloud-starter-sleuth

    <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

labidc avatar Dec 27 '18 18:12 labidc

I am very sorry, this is totally my mistake, I did not read the ribbon related documents carefully.

labidc avatar Dec 28 '18 10:12 labidc