Enabling /bus/refresh endpoint in Spring Cloud Config Client

12.9k Views Asked by At

My Spring Cloud Config Client has dependency to spring.cloud.starter.bus.amqp, but it is still not enabling /bus/refresh endpoint

build.gradle    
compile("org.springframework.cloud:spring-cloud-starter-stream-rabbit:1.1.3.RELEASE")    
compile("org.springframework.cloud:spring-cloud-starter-bus-amqp:1.2.2.RELEASE")

I have these dependencies in my config client application, but still not enabling /bus/refresh, /bus/env.

Please let me know what am I missing in my client application.

Note:

spring.cloud.bus.refresh.enabled: true
spring.cloud.bus.env.enabled: true
endpoints.spring.cloud.bus.refresh.enabled: true
endpoints.spring.cloud.bus.env.enabled: true

I have tried setting up these indicators in application.yml or application.properties as these are used by BusAutoConfiguration, to enable /bus/* endpoints.

@ConditionalOnProperty(value = "endpoints.spring.cloud.bus.refresh.enabled", matchIfMissing = true)

In my Spring Cloud Config Server application I have disabled these endpoints, i.e., set to false

endpoints.spring.cloud.bus.refresh.enabled: false
endpoints.spring.cloud.bus.env.enabled: false

and observed that during Spring Boot startup /bus/* endpoints are not being enabled.

5

There are 5 best solutions below

3
On BEST ANSWER

Did you map client's url to /bus/refresh? I believe it's mapped to /refresh by default.

You could also try sending a POST request to client app at:

curl -X POST http://server:port/refresh

I also believe you might not need spring-cloud-starter-stream-rabbit dependency, just spring-cloud-starter-bus-amqp.

BTW I published a detailed post with working demo at: Refreshable Configuration using Spring Cloud Config Server, Spring Cloud Bus, RabbitMQ and Git that might help you as a starting point.

0
On

After reviewing code, it is found that spring.cloud.config.bus.enabled is set to false or overridden.

I was using enterprise framework jar on that top of Spring Boot; which was having spring.cloud.config.bus.enabled as true in bootstrap.yml and but this was overridden by config server property file i.e., git properties files repository was having false as value and for which preference was given.

localhost:<port>/env

shall display all properties from different sources; like config server, application.yml as part of service jar. Out of one which gets preference.

"configService:github uri": { list of properties }
"systemProperties": { list of properties }
"applicationConfig: [classpath:/application.properties]": { list of properties }

Below spring env rest resource is being used to ensure the exact value of this property.

localhost:<port>/env/spring.cloud.config.bus.enabled
4
On

Updating this question with my findings as of 2018/04/12

/actuator/bus-refresh is the way to go from the config server.

In your application.properties:

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

Example: curl -X POST http://localhost:8080/actuator/bus-refresh

Signals all registered clients to update their configs.

Most of the existing articles I've found don't have this but I managed to find the simplest one based on trial and error and tidbits of solutions here.

0
On

Mine is YAML,but writing you .properties representation. after adding below options having an empty POST to config server port worked for me http://ourserver:1234/actuator/refresh

management.enpoints.web.exposure.include: info, health, refresh, bush-refresh
spring.cloud.config.sever.bus.enabled: true
0
On

I faced the exact same issue. My observations are as follows: I rectified that, the RabbitMQ/AMQP maven dependency as my primary issue.

My micro-service & springCloudConfigServer module are using the following: 2.2.4.RELEASE - Hoxton.SR1

My pom.xml is as follows:

        <!-- Use this! I replaced this maven dep. for following one -->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-bus-amqp</artifactId>
        </dependency>

        <!-- I was using this maven dep. initially which when replaced by the above solved my issue. Avoid using this for now.
        <dependency>
            <groupId>org.springframework.amqp</groupId>
            <artifactId>spring-rabbit</artifactId>
        </dependency>
        -->

My application.properties / bootstrap.properties is as follows:

management.endpoints.web.exposure.include=bus-refresh

This URL worked for me: http://localhost:8080/actuator/bus-refresh and not: /bus/refresh OR /bus/env

1) You need to have the spring-boot-starter-actuator and spring-cloud-starter-bus-amqp maven dependencies in both, micro-service module and your springCloudConfigServer module as well.

2) In my micro-service module, when I used spring-rabbit maven dep. & when I tried executing the URL: /actuator/bus-refresh it always failed with error response 404! for some reason.

3) Then, I updated my micro-service pom file from spring-rabbit to spring-cloud-starter-bus-amqp, & tried the same URL again. It worked! My deductions were simple. It's just that 'spring-rabbit' didn't support /actuator/bus-refresh for some reason for sure. (I learned this after doing a trial & error for same)

Hope this helps you. If it doesn't, you can refer this link & this also.