Spring Cloud basic introduction

1. Concept

Spring Cloud is a collection of organic framework to achieve a series of micro-services architecture.

Spring Boot is built on the basis of a simplified tool set for a distributed system constructed. It is a collection of project has many subprojects. The development of the use of Spring Boot convenience, skillfully simplifies distributed system infrastructure (service registration and discovery, fusing mechanism, gateway routing, distribution center, message bus, load balancing, link tracking, etc.) development.

2. Version

  1. Process version: Version Name the version number.

  2. Version name: London Underground alphabetical order.

  3. The version number: M (milestone): milestone,

    SR (Service Releases): stable version,

    RC (Release Candidate): stable release candidate version and final version of a stable version.

3. The overall architecture

  1. Service registration and discovery components: Eureka, Zookeeper, Consul, Nacos and so on. Eureka REST-based style.

  2. Service calling component: Hystrix (blown downgrade in the event of failure of the service depend on, rely on services by way of the isolation system to prevent cascading failure of service, while providing failed rollback mechanism, enabling the system to recover from the exception faster) , the Ribbon (client load balancing, load balancing algorithm provides software for a client, provides a comprehensive range of configuration items: connection timeout, retry, etc.), OpenFeign (the Ribbon elegant packaging, is a declarative RESTful web client request end, it makes writing Web service clients more convenient and faster).

  3. Gateway: routing and filtering. Zuul, Gateway.

  4. Configuration Center: provides centralized configuration management, dynamic refresh function configurations; configured to store Git or by other means.

  5. Message component: Spring Cloud Stream (distributed message abstraction, including publication subscriptions, consumer groups and other functions, to achieve asynchronous communication between the micro-services) and Spring Cloud Bus (mainly to provide communication between service events, such as refresh configuration)

  6. Security control assembly: Spring Cloud Security OAuth2.0 open standards-based security network, providing a single sign-on, resource authorization and token management.

  7. Link Trace components: Spring Cloud Sleuth (call collect data on the link), Zipkin (Sleuth information collected, stored, statistics show).

4.Spring Cloud Context

  1. We know that Spring Boot application context by application.yml configuration.

  2. Bootstrap context (Spring Cloud provides, also known as boot program context)

    Spring Cloud will start when a bootstrap create a context, which is the parent context of the application ( please note mentioned here refers to a bootstrap startup configuration item beginning with bootstrap.yml or is bootstrap.properties two different things ); it is responsible for some of the load from the external environment, configuration items, such as the distribution center; the priority of this part of the CI is the highest, so it will not be other configuration files to load configuration items to cover.

    It is the parent of the context of the main program, is responsible for loading configuration properties and decryption local external profile properties from external sources (Git repository). Spring is the source of all the external attributes of the program. Bootstrap higher priority by loading the incoming property, it can not be configured to cover locally.

    3. Load order

    Spring Cloud application configuration items can be loaded from the following location:

Start configuration items specified in the command -> configuration center profiles -> local application.properties (yml) -> Local boostrap.properties (yml) configuration items these positions down from the descending priority , that is, from an upper position to load configuration item overrides the loading position below the configuration item. The following code configured configuration items loaded in the center of a higher priority than configuration items loaded bootstrap.yml

    4.application context

Bootstrap application context is the context of the parent. Children inherit profiles and properties from the parent.

bootstrap.yml attributes added to the child context. Their priority is lower than application.yml and other additives to the child as to create a source Spring Boot application properties, boostrap.yml attributes have a very low priority, and therefore may be used as the default.

Bootstrap priority attribute context, it is noted that these properties do not include any attributes from bootstrap.yml.

5.Spring Cloud Commons

The service discovery, load balancing, circuit breakers and other packages in the Commons, Cloud for the client to use, does not depend on the specific implementation (Eureka, Consul), provides a similar set of specifications jdbc, database vendor to implement it.

E.g:

org.springframework.cloud.client.discovery.DiscoveryClient

Spring Cloud is the top-level interface for performing service discovery, or Consul in Netflix Eureka has a corresponding implementation class.

DiscoveryClient current implementation has Spring Cloud Netflix Eureka, Spring Cloud Consul Discovery and Spring Cloud Zookeeper Discovery.

org.springframework.cloud.client.serviceregistry.ServiceRegistry interface of the service registration and the service offline.

6. Summary

Best Spring Cloud floor plan is currently only Java world micro-services practice, is a service-based management tools Spring Boot package. And do not represent micro service or micro Services Architecture.

Micro Services is an architectural concept: a focus on micro-service design principles, can be achieved without Spring cloud micro services, focusing on architecture concept.

发布了45 篇原创文章 · 获赞 1 · 访问量 2486

Guess you like

Origin blog.csdn.net/Forest24/article/details/104597471