Spring Cloud Bus and Spring Cloud Config Server

Nil Seri
2 min readSep 18, 2021

Use Spring Cloud Bus and Spring Cloud Config Server Together

Photo by Yehor Litsov on Unsplash

Firstly, you can follow these instructions for Spring Cloud Server:

Add these to your dependencies as an extra for Spring Cloud Bus:

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-monitor</artifactId>
</dependency>

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

If you would like to inspect which dependencies in “spring-cloud-starter-bus-kafka”, these are the dependencies in version 3.0.3 (Here, I use a plugin called Maven Helper in IntelliJ to use “Dependency Analyzer” view in pom.xml file).

So, if you are already using “spring-kafka” as a dependency, you can remove it.

To be able to post our refresh command, you should add these properties to your config server’s application.properties:

spring.cloud.bus.enabled=true
management.endpoints.web.exposure.include=busrefresh

You can see allowed Actuator endpoints in IntelliJ ‘s related tab:

This is your cURL request (if you are using port no 8888 for your config server project):

curl -L -X POST 'http://localhost:8888/actuator/busrefresh'

After the POST request, go to your main project’s logs and see which keys are refreshed:

Voilà!

Happy Coding!

--

--

Nil Seri

I would love to change the world, but they won’t give me the source code | coding 👩🏻‍💻 | coffee ☕️ | jazz 🎷 | anime 🐲 | books 📚 | drawing 🎨