简体   繁体   中英

Is there any use of registering my config server in Eureka?

I'm specifying the config server URI spring.cloud.config.uri in the bootstrap.properties file of all my config server clients.

So is there any use of adding an @EnableDiscoveryClient annotation to it, and registering the configuration service in Eureka?

There are various use cases why registering your config server on Eureka could be useful:

Discovery-first bootstrapping

When using the Spring cloud config service, you have two choices when bootstrapping your application, as mentioned by the documentation :

  1. Using a config-first setup (default)
  2. Using a discovery-first setup

When you use a discovery-first setup, all applications can retrieve their configuration by looking up the URL of the configuration service on Eureka:

spring.cloud.config.discovery.enabled=true
spring.cloud.config.uri=http://config-service

In this case, the application will look for a service named config-service on Eureka, and will use the given hostname and port to connect.


Discoverability

Some tools, like Zuul, Spring boot admin, ... will automatically discover all applications and use them, for example:

  • Spring boot admin can be setup to automatically discover all applications to manage them.
  • Zuul will automatically forward all routes matching /{application-name}/** to the given application.

@EnableDiscoveryClient activates the Netflix Eureka DiscoveryClient implementation and tells it to register itself with a service registry.

So, without this annotation, your application will not able to register itself to any Registry. And hence will not be discovered from any service as well.


Edit : Registering your application to DiscoveryServer provides many benefits, some of them are below :

  • Application independence : When you register your application to DiscoveryServer it decouples it from another application. Doing so you don't need to hardcode the name and URL of your application in using application.
  • Load Balancing : Register your application to DiscoveryServer provides an effective and efficient way to provide load balancing.
  • Multiple instances of same application : In order to provide load balancing you can add multiple instances of a single application.
  • Resilience : When an instance is not working then Server can use the circuit breaker to handle requests effectively and helps in making system responsive and resilient.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM