Spring Cloud Netflix

Source: Internet
Author: User

The project provides the Netflix OSS integration to the Spring boot application through automatic configuration and is bound to the spring environment and other spring programming model idioms. With a few simple notes, you can quickly enable and configure common patterns in your application and build large distributed systems from tested Netflix components. The modes provided include service discovery (Eureka), Circuit breakers (Hystrix), intelligent routing (Zuul), and client load Balancing (Ribbon).

Service Discovery: Eureka Client

Service discovery is one of the key principles of micro-service architecture. Trying to configure each client or some form of convention can be very difficult and very fragile. The Netflix service discovers that servers and clients are Eureka. Servers can be configured and deployed as high availability, and each server replicates the state of the enrollment service to other servers.

How to include Eureka clients

To include the Eureka client in your project, use org.springframework.cloud spring-cloud-starter-eureka the initiator of the group and artifact IDs. For more information about building a system using the current Spring Cloud publishing list settings.

Register Eureka

When a client registers Eureka, it provides metadata about itself, such as host and port, health indicator URL, home page, and so on. Eureka receives heartbeat messages from each instance belonging to the service. If a heartbeat failure exceeds a configurable timesheet, the instance is typically removed from the registry.

Example Eureka Client:

  @Configuration @componentscan@enableautoconfiguration@enableeurekaclient@restcontroller  public  class   application {@RequestMapping ( "/"  public   String home () { return " Hello World ";  public  static  void   main (string[] args) { new Springapplicationbuilder (Application.    Class ). Web (true  

(That is, the fully normal spring boot application). In this example, we explicitly use @EnableEurekaClient , but only eureka available, you can also use @EnableDiscoveryClient . Configuration is required to locate the Eureka server. Cases:

Application.yml

Eureka:  client:    serviceurl:      defaultzone:http://localhost:8761/eureka/

where "Defaultzone" is a magic string fallback value that provides a service URL for any client that does not represent a preference (that is, it is a useful default value).

From Environment the default application name (service ID) obtained, the virtual host and the non-secure ports are ${spring.application.name} , respectively, ${spring.application.name} and ${server.port} .

@EnableEurekaClientThe application goes into a Eureka "instance" (that is, registering itself) and a "client" (that is, it can query the registry to find other services). The instance behavior eureka.instance.* is driven by the configuration key, but if you ensure that your application has spring.application.name (this is the default value for the Eureka Service ID or VIP), the default value will be normal.

Source source technical support for complete projects 1791743380

Spring Cloud Netflix

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.