SpringCloud from entry to entry

The modules included in springcloud:

1. Service registration and discovery 2. Service call 3. Service fuse 4. Load balancing 5. Service downgrade 6. Service message queue

7. Configuration center management 8. Service gateway 9. Service monitoring 10. Full link tracking 11. Automatic construction and deployment

12. Service timing task scheduling operation

version control sample

Key technology selection:

Service registry: Nacos

Service call: Ribbon OpenFeign

Service downgrade: spring cloud alibaba sentienl

Service gateway: gateway

Service Configuration: Nacos

Service Bus: Nacos

The core logic of distributed microservice architecture:

Conventions > Configuration > Encoding

Hot deployment:

Devtools

What is RestTemplate:

RestTemplate provides a variety of convenient ways to access remote Http services. 
It is a simple and convenient way to access restful service template classes. It is a client template tool set provided by Spring for accessing Rest services.

Use RestTemplate:


Using restTemplate to access the restful interface is very simple and rude.
(url, requestMap, ResponseBean.class) These three parameters respectively represent 
the REST request address, request parameters, and the object type converted into the HTTP response conversion.

Notice:

When using RestTemplate to link two microservice methods, you need to add the annotation @RequestBody before the passed entity class.

Introduce a useful tool package: Hutool:

Hutool - domestic conscience toolkit, make your java sweeter http://www.baidu.com/link?url=z92WLSS0jxe6nDf-taVoZL_TQ5842X2NqngkNuyWOL8kYQeW6G0_Wgr3zj9cLQRp

 Eureka service registration and discovery

What is Service Governance?

 Spring Cloud encapsulates the Eureka module developed by Netflix to implement service governance.
 
      In the traditional rpc remote call framework, it is more complicated to manage the dependencies between each service and the management, so it is necessary to use service governance to manage the dependencies between services and services. It can realize service invocation, load balancing, fault tolerance, etc., and realize service discovery and registration.


 What is service registration and discovery?

Eureka adopts the design architecture of CS. Eureka Server is the server of the service registration function, which is the service registration center. Other microservices in the system use Eureka's client to connect to Eureka Server and maintain a heartbeat connection. In this way, system maintainers can use Eureka Server to monitor whether each microservice in the system is running normally.
In service registration and discovery, there is a registry. When the server starts, it will register the information of the current server, such as the service address and mailing address, to the registration center in the form of an alias. The other party (consumer | service provider) uses the alias to obtain the actual service communication address from the registration center, and then realizes the local RPC call RPC remote call framework. The core design idea: lies in the registration center, because the registration center is used to manage a dependency between each service and the service (service governance concept). In any rpc remote framework, there will be a registration center (store service address related information (interface address))

 Two components of Eureka:

  
Eureka consists of two components: Eureka Server and Eureka Client.
 
Eureka Server provides service registration service
. After each microservice node is configured and started, it will be registered in EurekaServer, so that the service registry in EurekaServer will store the information of all available service nodes, and the information of service nodes can be seen directly in the interface.
 
 
EurekaClient accessed through the registry
is a Java client that simplifies the interaction with Eureka Server. The client also has a built-in load balancer that uses a round-robin load algorithm. After the application starts, a heartbeat will be sent to Eureka Server (the default period is 30 seconds). If Eureka Server does not receive a node's heartbeat within multiple heartbeat cycles, EurekaServer will remove the service node from the service registry (90 seconds by default)

@EnableEurekaServer annotation:

Which microservice startup class is placed on represents which class is the service registry, which configures, registers and registers


 
 
 
 
 

Guess you like

Origin blog.csdn.net/qq_39367410/article/details/128037876
Recommended