Feign整合Ribbon負載均衡


backend_show_consumer工程

1、在 中配置FeignClient,name為back_show_provider的hello-service-provider

 

 

2、負載均衡器配置如下

@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、測試

來自7101端口服務返回的數據

 

倆字7102端口返回的數據

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM