3

I'm using Ribbon along with Eureka.

My application is able to call the other-service in both the following configurations. I'm using NIWSServerListClassName in first and listOfServers in second.

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

I've seen both NIWSServerListClassName and listOfServers being used in spring-cloud-netflix GitHub issues (and in some places in docs also) for getting server list for ribbon.

What is the difference between these two ribbon properties? Do they serve the same purpose?

Cœur
  • 37,241
  • 25
  • 195
  • 267
narendra-choudhary
  • 4,582
  • 4
  • 38
  • 58

1 Answers1

3

The documentation below explains that listOfServers is for Ribbon, and gets overridden if Eureka is used.

6.5 Using Ribbon with Eureka

When Eureka is used in conjunction with Ribbon (that is, both are on the classpath), the ribbonServerList is overridden with an extension of DiscoveryEnabledNIWSServerList, which populates the list of servers from Eureka.

They go on to say that when Eureka is not used, you may use listOfServers:

However, if you prefer not to use Eureka, Ribbon and Feign also work..... You can supply the configuration as follows stores:
ribbon: listOfServers: example.com,google.com

From: https://cloud.spring.io/spring-cloud-netflix/multi/multi_spring-cloud-ribbon.html

Gonen I
  • 5,576
  • 1
  • 29
  • 60
  • 1
    I was able to figure out the difference using spring-cloud documentation, but did not post an answer. Thank you for posting the answer, I've accepted it. – narendra-choudhary Nov 10 '18 at 15:58