HealthCheckService

This SPI service allow runtime infrastructure such as Kubernetes or Docker Swarm to monitor the app and (potentially) restart it if required.

This SPI service integrates with Spring Boot’sHealthIndicatorSPI, surfaced through theSpring Boot Actuator. It is therefore accessible from the /actuator/health endpoint (Spring allows the endpoint URL to be altered or suppressed).

The service, when called, will be within the context of a special internal user health with the internal role health-role .

API

HealthCheckService.java
interface HealthCheckService {
  Health check()
}

Implementation

The framework provides no default implementation, but the simpleapp starter app provides a sample implementation:

@Service
@Named("domainapp.HealthCheckServiceImpl")
@Log4j2
public class HealthCheckServiceImpl implements HealthCheckService {

    private final SimpleObjects simpleObjects;

    @Inject
    public HealthCheckServiceImpl(SimpleObjects simpleObjects) {
        this.simpleObjects = simpleObjects;
    }

    @Override
    public Health check() {
        try {
            simpleObjects.ping();
            return Health.ok();
        } catch (Exception ex) {
            return Health.error(ex);
        }
    }
}

The internal domain service o.a.c.core.webapp.health.HealthIndicatorUsingHealthCheckService acts as the bridge between Spring and the `HealthCheckService' SPI.