Spring Cloud Netflix:ribbon.NIWSServerListClassName和ribbon.listOfServers之间有什么区别?

时间:2018-05-07 05:54:48

标签: spring-cloud netflix-eureka spring-cloud-netflix netflix-ribbon

我和Eureka一起使用Ribbon。

我的应用程序可以在以下两种配置中调用其他服务。我先使用NIWSServerListClassName,然后使用listOfServers

other-service:
  ribbon:
    eureka:
      enabled: true
    NIWSServerListClassName: com.netflix.niws.loadbalancer.DiscoveryEnabledNIWSServerList
    ServerListRefreshInterval: 1000

other-service:
  ribbon:
    eureka:
      enabled: true
    listOfServers: com.netflix.niws.loadbalancer.DiscoveryEnabledNIWSServerList
    ServerListRefreshInterval: 1000

我在spring-cloud-netflix GitHub问题中(以及在docs中的某些地方)使用了NIWSServerListClassNamelistOfServers来获取功能区的服务器列表。

这两个功能区属性有什么区别?他们是否有同样的目的?

1 个答案:

答案 0 :(得分:1)

下面的文档说明listOfServers适用于Ribbon,如果使用Eureka,它将被覆盖。

  

6.5将功能区与Eureka一起使用

     

当Eureka与Ribbon结合使用时(也就是说,两个都在   类路径),ribbonServerList被扩展覆盖   DiscoveryEnabledNIWSServerList的列表,该列表填充服务器列表   来自尤里卡。

他们继续说,当不使用Eureka时,您可以使用listOfServers:

  

但是,如果您不想使用Eureka,Ribbon和Feign,   您可以在以下商店中提供配置:
  带:       listOfServers:example.com,google.com

发件人: https://cloud.spring.io/spring- cloud-netflix / multi / multi_spring-cloud-ribbon.html