[SpringCloud] Gateway gateway, SpringCloud Config configuration center, message bus BUS and Spring Cloud Stream

1. Gateway gateway

API Gateway is a server, which can also be said to be the only node entering the microservice system, and provides APIs to each client. It can also have other functions, such as authorization, monitoring, load balancing, caching, request fragmentation and management, Static response handling, etc.
API Gateway is responsible for request forwarding, synthesis and protocol conversion. All requests from clients will go through API Gateway first, and then load balance these requests to the corresponding microservices.
The three core concepts of GateWay :
insert image description here
specific usage : Introduction to Gateway and
the dependencies required for use

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-gateway</artifactId>
</dependency>

Only one startup class, gateway configuration file, application.,yml is needed

server:
  port: 9527
spring:
  application:
    name: cloud-gateway
  cloud:
    gateway:
      routes:
        - id: payment_routh #路由的id,没有固定的要求,唯一即可,建议匹配服务名
          uri: http://localhost:8001  #匹配后提供服务的路由地址
          predicates:
            - Path=/payment/get/**  #断言,路径相匹配的进行路由

        - id: payment_routh2 #路由的id,没有固定的要求,唯一即可
          uri: http://localhost:8001  #匹配后提供服务的路由地址
          predicates:
            - Path=/payment/lb/**  #断言,路径相匹配的进行路由
eureka:
  instance:
    hostname: cloud-gateway-service
  client: #将服务提供者注册进eureka中
    service-url:
      register-with-eureka: true
      fetch-registrer: true
      defaultZone: http://eureka7001.com:7001/eureka

Two, distributed configuration center SpringCloud Config

The fourth of the Spring Cloud learning series ----- Configuration Center (Config) detailed explanation
insert image description here
1. The Spring Cloud Config project is a configuration management solution for distributed systems. Contains two parts, Client and Server.
① The server is an independent microservice application, mainly used to manage the configuration of various environments under the application program. By default, Git, local or VSN storage is used to store configuration files and provide the content of configuration files in the form of interfaces;
② The client is each micro-service application. It manages application resources and business-related configuration content through the designated configuration center, and obtains and loads configuration information. 2.

What is the use of Spring Cloud Config?
Spring Cloud Config provides centralized external configuration support for microservices in the microservice architecture, and the configuration server provides a centralized external configuration for all environments of different microservice applications.
insert image description here
3. How to realize the dynamic refresh of Config?
insert image description here
The operation and maintenance personnel use the command line to manually send the post request to avoid restarting the client service.

3. Message bus (BUS)

Spring Cloud Bus is a framework used to link distributed system nodes with lightweight messages, integrating Java's event processing mechanism and message middleware functions. Spring Cloud Bus currently supports RabbitMQ and Kafka.
1. What is a bus?
In a system with a microservice architecture, a lightweight message broker is usually used to build a common message topic and connect all microservice instances in the system. Since the messages generated in this topic will be monitored and consumed by all instances, it is called a message bus.
RabbitMQ installation and configuration under Windows
2. Dynamic refresh of all clients (Config Client)
insert image description here
2. Fixed-point refresh of some clients (Config Client)
insert image description here

四、Spring Cloud Stream

insert image description here
1. Spring Cloud Stream is a framework for building message-driven microservices.
By defining the binder Binder as the middle layer, the isolation between the application program and the details of the message middleware is realized.
insert image description here
2. The message communication method in Stream follows the publish-subscribe model.
3. Comments commonly used in Steam:
insert image description here

Guess you like

Origin blog.csdn.net/weixin_46081857/article/details/123542045