config distributed configuration center and service bus bus

Why would config be introduced? Look at the picture below:

 config contains client and server:

Service 3344 is the server of the configuration center:

Create 3344 service steps: 

 pom.xml:

Startup class: config server should be added to enable @EnableConfigServer 

 

application.yml: 

 

Configuration file reading rules: the figure below

 config client configuration: service 3355

 

 

controller: 

 Understanding: 3344 service is the server of config, 3344 is connected to github; 3355 is connected to 3355 as the client of config; through the test interface of the above 3355 service, the result of calling the 3344 service is the same. The relationship is 3344 to github, 3355 to 3344

The question ensues, the dynamic refresh of the distributed configuration?

 The modification of manual dynamic refresh is as follows: the steps are as shown in Figure 1, and then the operation and maintenance personnel need to send a POST request to refresh 3355, that is:

 

 Operation and maintenance personnel post request:

At this point, the client service restart is avoided! But it is not the most optimized and perfect solution. If there are 100 microservices, wouldn't it be necessary to send 100 requests for operation and maintenance?

So it needs to be refreshed automatically, not the above manual refresh:

 At this point, the concept of service bus needs to be introduced:

 There are two schemes for automatic refresh: Look at the picture below, but 1 is not very reliable, so scheme 2:

 The following is the flow chart of the ideas of options 1 and 2:

 

Start to transform: Both the config server and the client need to introduce RabbitMQ:

 Server 3344 transformation: 

 

The client modification 3355 is the same as 3366:

 

 

If the operation and maintenance personnel modify or change the configuration file in github, first 3344 is directly connected to github, and 3344 will automatically change the corresponding configuration file. At this time, after the above configuration, only need to send a POST request to refresh 3344 and it is ok. 3355 and 3366 will also automatically refresh the latest configuration files. 

You can also customize to refresh: the following figure

 The first is a global notification, 3355 and 3366 will refresh the configuration file; the second is a partial refresh, only 3355 is refreshed, where config-client is the service name.

Guess you like

Origin blog.csdn.net/zhangleiyes123/article/details/106907750