Spring Cloud
Spring Cloud provides tools for developers to quickly build common distributed systems such as configuration management, service discovery, circuit breakers, intelligent routing, micro-proxies, control buses, one-time tokens, global locks, leader elections, distributed sessions, and cluster status.
This is the latest version Edgware
Operation Steps
1. Create a new project as Eureka Server
After the creation of the completed Pom.xml file is this
Next, run a Eureka Server
So, in the end, the project looks like this.
After startup, enter http://localhost:8761/in the browser to see the following interface
2. Next, build another project as Eureka Client. The only difference is that the artifact ID is replaced with spring-cloud-starter-netflix-eureka-client
And then it's all translated from the official document. Part III of Spring Cloud Netflix chapter 11th
11.2 Registering with Eureka
When the client registers with Eureka, it provides its own metadata, such as the host, port, URL, home address, and so on. Eureka receives heartbeat messages for all instances under a service. If heartbeat detection fails (exceeding the configured timeout), then this instance is usually removed from the registration list.
as long as there is spring-cloud-starter-netflix-eureka-client under the classpath of your app, it will be automatically registered to Eureka Server. of course, you need to configure the Eureka server address. For example:
The default app name, virtual host, and unsecured ports are represented by ${spring.application.name}, ${spring.application.name}, and ${server.port}, respectively。
If you do not want Eureka to discover the client, you can set the value of eureka.client.enabled to False
So
Observe the boot logs on both sides
Now look at http://localhost:8761/.
11.4 Status Page and Health Indicator
The status page and health indicator for Eureka instances are represented by "/info" and "/health", respectively. Of course, this can be changed. The default is like this
11.6 Eureka ' s Health Checks
By default, Eureka uses the client heartbeat detection to determine if a client is alive. This client will not propagate the health check status of this app to each spring boot monitor unless there is a special case. This means that after the registration is successful, it is always declared that the application is an "up" state. This behavior can be changed by Eureka Health Check, and the result of this change is to spread the state of the application to Eureka
Note: Eureka.client.healthcheck.enabled=true should only be written in Application.yml.
11.7.3 changing the Eureka Instance ID
The format of the default instance ID is this: ${spring.cloud.client.hostname}:${spring.application.name}:${spring.application.instance_id:${ Server.port}}}
Of course, you can override this default setting with Eureka.instance.instanceId
Springcloud Study Notes (1)--eureka