zm
2020-05-18 a18bfacbf56b401f6e0fdae8710fbca4df8cff77
commit | author | age
a18bfa 1 package com.changhong.epc.zuul.config;
Z 2
3 import java.io.File;
4 import java.net.MalformedURLException;
5 import java.net.URL;
6 import java.net.URLEncoder;
7 import java.util.Arrays;
8
9 import org.bouncycastle.crypto.tls.URLAndHash;
10 import org.springframework.beans.factory.annotation.Autowired;
11 import org.springframework.boot.web.client.RestTemplateBuilder;
12 import org.springframework.cloud.client.loadbalancer.LoadBalanced;
13 import org.springframework.context.annotation.Bean;
14 import org.springframework.context.annotation.Configuration;
15 import org.springframework.context.annotation.Scope;
16 import org.springframework.http.MediaType;
17 import org.springframework.web.client.RestTemplate;
18
19 import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter4;
20 import com.iemsoft.framework.cloud.zuul.config.ZuulHystrixConfig;
21 import com.netflix.loadbalancer.BestAvailableRule;
22 import com.netflix.loadbalancer.IPing;
23 import com.netflix.loadbalancer.IRule;
24 import com.netflix.loadbalancer.PingUrl;
25
26 @Configuration
27 public class RibbonConfiguration extends ZuulHystrixConfig{
28     
29     /**
30      * ping中心
31      * @return
32      */
33     @Bean
34     public IPing ribbonPing() {
35         return new PingUrl(false, "/info.json");
36     }
37     
38     /**
39      * 
40      * @return
41      */
42     @Bean
43     @Scope("prototype")
44     public IRule ribbonRule() {
45 //        return new BestAvailableRule(); //閫夋嫨涓�涓渶灏忕殑骞跺彂璇锋眰鐨剆erver
46 //        return new WeightedResponseTimeRule(); //鏍规嵁鐩稿簲鏃堕棿鍒嗛厤涓�涓獁eight锛岀浉搴旀椂闂磋秺闀匡紝weight瓒婂皬锛岃閫変腑鐨勫彲鑳芥�ц秺浣庛��
47 //        return new RetryRule(); //瀵归�夊畾鐨勮礋杞藉潎琛$瓥鐣ユ満涓婇噸璇曟満鍒躲��
48 //        return new RoundRobinRule(); //roundRobin鏂瑰紡杞閫夋嫨server
49 //        return new RandomRule(); //闅忔満閫夋嫨涓�涓猻erver
50 //        return new ZoneAvoidanceRule(); //澶嶅悎鍒ゆ柇server鎵�鍦ㄥ尯鍩熺殑鎬ц兘鍜宻erver鐨勫彲鐢ㄦ�ч�夋嫨server
51         return new BestAvailableRule();
52     }
53     
54 }