12

If Eureka client doesn't register itself with the eureka server by setting eureka: client: registerWithEureka: false, why does fetchRegistry property also needs to be set as false?

1

3 Answers 3

13

registerWithEureka controls whether or not this client registers itself and therefore becomes discoverable. This alone does not imply that this client is going to fetch the information on other services' endpoints and therefore being able to connect to them.

fetchRegistry controls whether or not this client is going to try to connect to the Eureka server(s) in order to download the information on other services' endpoint. It can do so without registering itself. Quoting the documentation:

Fetch Registry

Eureka clients fetches the registry information from the server and caches it locally. After that, the clients use that information to find other services.

6

Eureka client need to register with eureka server to become discoverable. Eureka server can act as client as well. So setting registerWith Eureka and fetchRegistry to false is mandatory

Only clients need to fetch registry to get the registered microservices for communication EurekaServer need not register itself and also need not fetch other registered Microservices

1
  • 1
    "setting registerWith Eureka and fetchRegistry to false is mandatory" - what if you want multiple Eureka servers to register with each other to create a network of nodes? If a eureka server registers with another server, and both fetch each others registry, do they not create a virtual cluster? Especially if you add Zuul, services from one node should failover to another node if they are grouped this way. Commented Jun 26, 2023 at 15:42
1

Two properties, eureka.client.fetch-registry and eureka.client.register-with-eureka, are properties that you might set on another microservice to tell them how they should interact with Eureka. But Eureka is also a microservice, so these properties can be used with a Eureka server to tell it how it should interact with other Eureka servers.

The default value for both of these properties is true, indicating that Eureka should fetch the registry from other Eureka instances, and it should register itself as a service with the other Eureka servers

if there aren’t other Eureka servers when in development mode, you’re setting them to false so that Eureka won’t try to reach out to other Eureka servers.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.