Enabling /bus/refresh endpoint in Spring Cloud Config Client

Viewed 11020

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.

4 Answers

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.

Related