Spring Cloud Learning Notes-003

Source: Internet
Author: User

Spring Cloud Learning Notes-003

    • Service provider: Registering the service with the registration center

1. New Maven project, skeleton selection QuickStart, project name: Demo-member

2. Join related dependencies:

3. Write the Service interface:

4. Create a new Application.yml file in the Src\main\resources directory:

5. Write the Startup class:

6. Start the project and visit the Eureka homepage to view the results (note: To start the Eureka Registry first):

7. Sometimes you will see this red warning message when you start Eureka:

This warning is triggering the Eureka server's self-protection mechanism . When the service is registered with Eureka Server, a heartbeat connection is maintained, telling Eureka that the server is alive. Eureka server During the run, will be counted whether the rate of heartbeat failure is less than 85% in 15 minutes, if there is less than the situation (when the single-machine debugging is easy to meet, the actual production environment is usually caused by network instability), Eureka The server protects the current instance registration information so that the instances do not expire and protects the registration information as much as possible. However, if there is a problem in this protection device instance, then the client (service provider or service consumer) can easily get the service instance that does not exist, so the client must have fault-tolerant mechanism such as request retry, circuit breaker and so on.

Because local debugging can easily trigger a registry protection mechanism, this makes the service instances maintained by the registry less accurate. Therefore, when we are developing locally, we can use the Eureka.server.enalbe-self-preservation=false parameter to turn off the protection mechanism to ensure that the registry can remove the unavailable instances correctly.

Spring Cloud Learning Notes-003

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.