When I try to activate the health indicator for the kafka binder as explained in Spring Cloud Stream Reference Documentation
the health endpoint returns:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-binder-kafka</artifactId>
<version>1.3.0.RELEASE</version>
</dependency>
management.health.binders.enabled = true management.health.kafka.enabled = true
management.endpoint.health.enabled=true management.endpoint.health.show-details=ALWAYS
localhost:8080/actuator/health
{
"status": "UP",
"details": {
"kafka": {
"status": "UP"
},
"diskSpace": {
"status": "UP",
"details": {
"total": 274622050304,
"free": 269098790912,
"threshold": 10485760
}
}
}
}
@Component
public class KafkaHealthIndicator implements HealthIndicator { private final Logger log = LoggerFactory.getLogger(KafkaHealthIndicator.class);
private KafkaTemplate<String, String> kafka;
public KafkaHealthIndicator(KafkaTemplate<String, String> kafka) {
this.kafka = kafka;
}
/**
* Return an indication of health.
*
* @return the health for Kafka.
*/
@Override
public Health health() {
try {
kafka.send("kafka-health-indicator", "❥").get(100, TimeUnit.MILLISECONDS);
} catch (InterruptedException | ExecutionException | TimeoutException e) {
return Health.down(e).build();
}
return Health.up().build();
}
}
It looks like a bug in the documentation. By default, the binders health indicators are enabled. If you want to disable, then you would need to specify management.health.binders.enabled=false
.
Thanks for reporting this.