Search code examples
springspring-bootconsulservice-discovery

Spring Cloud Consul's discovery client returns failing instances


I use Spring Cloud Consul to discover the services I need for my application. The discovery client returns all registered instances for the requested service although I also returns failing instances.

Consul itself marks the failing instances corretly as failed (critical).

So, why does the discovery client not remove critical/failed instances? Or is where is the documentation which describes this?


Solution

  • After reading the source of Spring Cloud Consul I found out that I have to set the property spring.cloud.consul.discovery.queryPassing as follows

    java -Dspring.cloud.consul.discovery.queryPassing=true ...`
    

    The relevant source files are:

    After setting this property the discovery client for Consul will return only those instance which pass all Consul health checks.