Preface:

1.1. The following is a summary of my experience through reading the official documentation and successful practice, hoping to help you understand and use Spring Cloud faster.

1.2. The default reader is already familiar with Spring buckets,Spring Boot and annotation development.

1.3. Updated in succession

2. Development environment: @deprecated

2.1. Development tool: IDEA

2.2. Development environment: JDK1.7

2.3. The Spring version:

2.3.1. Spring the Boot: 1.4.0 release

Spring Cloud: Camden SR2

3. The demo: (to eager to crash each big brother) : demo address: https://github.com/leoChaoGlut/spring-cloud-demo

3.1. Service Registration Demo:

3.1.1. Create an engineering module, as shown in the figure

3.1.2. Add officially provided Maven dependencies to POM.



3.1.3. As shown in the figure, Discovery is completed


3.1.4. As shown in the figure, Service0 and Service1 are similar


3.1.5. As simple as explosion there is no……….. Next, start Discovery, then Service0 and Service1

3.1.6. Open a browser and access localhost:8080, which is the port number configured in Discovery. If all goes well, you can see:


3.1.7. Services Service0 and Service1 have been registered

3.2. Gateway Demo: It is not enough just to register the service. Here we can configure another gateway, so that the service invocation has a unified entry.


3.2.1. After the above configuration, Discovery is started first, followed by services and gateways in random order. By accessing localhost: 8083 / service0 / service0, can see, the gateway to help us forward the request.

3.3.Feign: A Spring Cloud component that turns a remote service provider’s REST interface into a local method call

Here’s an example:

There are now two services, Service0 and Service1

Service0 provides a test interface,

In this case, if Service1 needs to call Service0, it can also use Feign to change the remote interface of Service0 into a local method call, in addition to the zuul call. As shown in figure:



4.feign + ribbon + hystrix

Brief introduction:

Hystrix: Based on the principle of section, the method can be added with a timeout indicator without invading the business code, and the specified fallback method can be called after the set indicator is exceeded, and the failure callback process can be carried out.

ribbon: Client load balancing, I once wrote a similar thing (https://github.com/leoChaoGlut/ServiceDIscoveryAndRegistry/tree/master/doc), but later found the spring Cloud already had mature, ready-made, common components, so it was abandoned. Ha ha… Old-fashioned, registrie-free service invocation is done through urls, but the Ribbon lets you invoke multi-instance services by providing the service name and load distribution on the client side to lighten the load on the server side.

Feign: It gives you an RPC-like experience in Http form.

Take a look at the graphics and code to get started with feign + Ribbon + Hystrix


Take a look at the official documentation of Spring Cloud, Feign, Ribbon, and Hystrix, plus read the source code, to learn how to use Spring Cloud to configure these three components.

5. Distributed application log tracking: Spring Cloud Sleuth:

http://blog.csdn.net/lc0817/article/details/72829935

6. Distributed configuration center: Spring Cloud Config

http://blog.csdn.net/lc0817/article/details/72833007

7. Spring Cloud Bus:

http://blog.csdn.net/lc0817/article/details/72836236

8.Net Flix Basic Components :Feign Ribbon Hystrix integrated in detail

http://blog.csdn.net/lc0817/article/details/72875195

9. Stream processing :Spring Cloud Stream

http://blog.csdn.net/lc0817/article/details/72956321


Original: https://blog.csdn.net/lc0817/article/details/53266212