Implementing Spring Cloud Bus
In this section, when we make the changes in the Git repository, we have to hit multiple instances of the limits-service to refresh the configuration.
We will invoke one URL, and it will reflect all the hundred instances of the microservices. Here we will use Spring Cloud Bus. There are many options available in the Spring Cloud Bus: Apache Kafka, RabbitMQ, etc. In this section, we will use RabbitMQ.
Note: Before moving to the next step, make sure that the RabbitMQ server is running in the background.
Let’s implement the Spring Cloud Bus in limits-service and spring-cloud-config-server.
Step 1: Open the pom.xml file of limits-service and spring-cloud-config-server project. Add the amqp dependency and save the file to reflect the changes.
Step 2: Open bootstrap.properties file and disable the management security by adding the following statement:dependency and save the file to reflect the changes.
Step 3: First, run the SpringCloudConfigServerApplication.java file and then run the two instances of limits-service: LimitsServiceApplication and LimitsServiceApplication8081.
Step 5: Invoke the URL http://localhost:8080/limits. It returns the following response:dependency and save the file to reflect the changes.
Now, invoke the URL http://localhost:8081/limits. It also returns the same response.
Step 6: Open the limits-service-qa.properties file and change the minimum value from 22 to 29.
Now we have to commit the changes.
Step 7: Open the Postman and send a POST request with the URL http://localhost:8080/bus/refresh.
Note: If you are using Spring Boot 2.0.0 or above versions, use the following URL: