Spring Cloud Bus - Refresh a specific cluster of client

1.3k Views Asked by At

I have a spring cloud config server configured over spring cloud bus over kafka. I am using Edgware.RELEASE with boot 1.5.9. When I send a POST request to the endpoint /bus/refresh with destination=clientId:dev:** in the body via POSTMAN to config server, all the clients get their beans refreshed even though their clientId doesn't match the value in the destination field.

Here are additional configuration details:

spring cloud config server

pom.xml

    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-config-server</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>

application.properties

server.port=8888
management.security.enabled=false
spring.cloud.bus.enabled=true
spring.kafka.bootstrap-servers=localhost:9092

I have two config clients with id - config-client1 and config-client2

After changing an application property in the repository for config-client2, I submit a POST request to /bus/refresh endpoint on the config server, with destination=config-client2:dev:** in the body of the request. I was hoping this would refresh/re-initialize the beans only in config-client2 application. But I noticed beans in config-client application are also refreshed/re-initialized. I also noticed config-client application receiving refresh event along with config-client2.

I was hoping only config-client2 application receives the event and its beans are the only ones that are refreshed as a result of it.

Wondering if I am missing any configuration setting to enable granular refresh at specific client level.

I did go through the document posted at - http://cloud.spring.io/spring-cloud-static/Edgware.RELEASE/single/spring-cloud.html, but the results are not as explained.

Any help with a working example is appreciated.

1

There are 1 best solutions below

0
On

You can use:

curl -X POST http://localhost:8001/actuator/bus-refresh/config-client2

You also need this in your application.properties or .yml.

spring.cloud.config.uri=http://localhost:8001

spring.cloud.config.uri should point to your Spring Config Server