I would like to disable the rabbit health check in my default RabbitMockConfiguration.
We have a Configuration that is imported via @Import
. Unfortunately the Configuration does not prevent the health check from being added to the health indicator as that happens once spring-rabbit is in the classpath.
We have the workaround, that we add a properties file in every service using that Configuration, which disables the property management.health.rabbit.enabled
, but for us it would be much nicer to be able to disable that heathcheck on configuration level.
I thought about the tests with @TestPropertySource(properties = ["management.health.rabbit.enabled=false"])
, but I could not find an equivalent to use for the a @Configuration
, as @PropertySource
expects a location for a properties file and does not accept single properties.
Any idea what we can do?
Spring boot version: 2.2.4
Spring amqp version: 2.2.3
Spring Version: 5.2.3
If you want to change the behaviour of the health check, I'd rather override the health check so that it states Rabbit is in mock mode.
To do so, just create a HealthIndicator
bean named rabbitHealthIndicator
:
@Bean
public HealthIndicator rabbitHealthIndicator() {
return () -> Health.up().withDetail("version", "mock").build();
}
This has the effect of switching the production one and exposes the fact the app is running with a mock.