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 the initiator of group Org.springframework.cloud and artifact ID spring-cloud-starter-eureka. 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:

@Configurationbr/> @ComponentScan
@EnableEurekaClient

public class Application {

@RequestMapping("/")public String home() {    return "Hello world";}public static void main(String[] args) {    new SpringApplicationBuilder(Application.class).web(true).run(args);}

}
(That is, the fully normal spring boot application). In this example, we explicitly use @enableeurekaclient, but only Eureka is available, and you can 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).

The default application name (service ID) obtained from environment, the virtual host and the unsecured port are ${spring.application.name},${spring.application.name} and ${server.port respectively }。

@EnableEurekaClient the application 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 is driven by the eureka.instance.* configuration key, but if you make sure that your application has spring.application.name (which is the default value for the Eureka Service ID or VIP), the default value will be normal.

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.