An overview,

1. What is it

Bus supports two message brokers, RabbitMQ and Kafka. Bus, in conjunction with Config, uses dynamic refreshes to implement configuration. A framework for linking nodes of distributed systems with lightweight messaging systems integrates Java’s event handling mechanisms and message-oriented middleware capabilities.

2. What can you do

BUS manages and propagates messages between distributed systems, acting as a distributed actuator that can be used to broadcast status changes, event push, etc., and can also act as a communication channel between micro-services.

3. What is the bus and its basic principle

What it is: In a microservice architecture system, it is common to use a lightweight message broker to build a common message topic and connect all microservice instances in the system. Since messages generated in this topic are listened to and consumed by all instances, it is called a message bus. Rationale: ConfigClient instances are all listening to the same topic in MQ (Bus by default). When a service refreshes data, the message is inserted into the topic so that other services listening on the same topic can be notified and update their configuration.

2. BUS refreshes global broadcast dynamically

  1. Must have a good MQ environment
  2. Demonstrate broadcast effect, add complexity. Add Configuration Center Client B
  3. 1) Use the message bus to trigger a client /bus/refresh, and refresh the configuration of all clients. 2) Use the message bus to trigger the/Bus/Refresh endpoint of a server configServer, while refreshing all client configurations. 3) The reason for choosing the second method is that it breaks the oneness of responsibility of micro-service. Micro-service itself is a business module and should not undertake the responsibility of configuration refresh. It destroys the equivalence of each node of micro-service; There are certain limitations.
  4. Configure the central server to add message bus support
Rabbitmq. host= address rabbitmq.port= port rabbitmq.username= username rabbitmq.password= password 2) exposure bus refresh configuration endpoint management endpoints. Web. Exposure. Include = 'bus - refresh'
  1. Configure Central Client A to add message bus support
Rabbitmq. host= address rabbitmq.port= port rabbitmq.username= username rabbitmq.password= password 2) exposure bus refresh configuration endpoint management endpoints. Web. Exposure. Include = '*'
  1. Configure central client B to add message bus support (same as client A)
  2. Modify the configuration file on GitHub, send a POST request, find that the client has been refreshed, one change broadcast notification, everywhere in effect. POST request: CURL-X POST: “Actuator/Bus-refresh”

    3. Bus dynamic refresh fixed point notification

    I don’t want to give you all the notices, I just want to give you all the notices. Specifies that a specific instance is valid instead of all; Formula: http://localhost:3344/actuator/bus-refresh/ {destination}; The /bus/refresh request is no longer sent to a specific service instance. Instead, it is sent to the config server, specifying the service or instance (service name + port number) that needs to be updated with the destination parameter.