Feign integration Ribbon Load Balancing

backend_show_consumer project

1, in the configuration FeignClient, name of back_show_provider the hello-service-provider

 

 

2, the load balancer is configured as follows

@Configuration
public class RestConfig {

    @Bean
    @LoadBalanced
    public RestTemplate restTemplate(){
        return  new RestTemplate();
    }

    /**
     * 负载均衡规则
     * @return
     */
    @Bean
    public IRule iRule(){
        return new RoundRobinRule();
        //return new MyRule();
    }

    @Bean
    public IPing iPing(){
        //return  new PingUrl(false,"/abc");
        return  new NIWSDiscoveryPing();
    }
}

  

3, the test

Data from the 7101 return of port services

 

Liang Zi returned data port 7102

 

 

Guess you like

Origin www.cnblogs.com/linlf03/p/12546054.html