Search code examples
spring-cloudnetflix-zuulnetflix-ribbon

zuul multiple urls one path


Hi I have a route that can have multiple servers...

I have tried the following to no luck:

zuul.routes.example.path=/example/**
zuul.routes.example.serviceId=example
example.ribbon.eureka.enabled=false
example.ribbon.eureka.listOfServers=http://127.0.0.1/metrics,http://127.0.0.1/info

This just returns the following error:

Caused by: com.netflix.client.ClientException: Load balancer does not have available server for client: example

I am using eureka for most routes, but for this one in particular I cannot use eureka.

Is it possible to get zuul to loadbalance between the two urls?

Solved

The answer below solves this issue with config, however I would mention I was using spring-boot-starter-parent, I also had to upgrade the dependency management to Camden.SR7

<dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-dependencies</artifactId>
<!--         <version>Brixton.SR5</version> -->
        <version>Camden.SR7</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>

Solution

  • Yes, you can. Try the following properties instead of yours.

    zuul.routes.example.path=/example/**
    zuul.routes.example.serviceId=example
    example.ribbon.NIWSServerListClassName=com.netflix.loadbalancer.ConfigurationBasedServerList
    example.ribbon.listOfServers=http://127.0.0.1/metrics,http://127.0.0.1/info