The GuicedEE Health module provides a seamless integration between Vert.x 5 Health Checks and the Eclipse MicroProfile Health API. It allows developers to define health checks using standard MicroProfile annotations and exposes them through Vert.x Web endpoints.
- MicroProfile Health Support: Full support for
@Liveness,@Readiness, and@Startupannotations. - Automatic Discovery: Automatically scans and registers health check classes in the Guice context.
- Vert.x 5 Integration: Leverages
vertx-health-checkfor robust, non-blocking health monitoring. - Configurable Endpoints: Custom paths for health, liveness, readiness, and startup checks via annotations.
- Aggregated Status: A unified
/healthendpoint that combines all registered checks. - Lifecycle Aware: Integrated with GuicedEE's
PreStartupandPostStartupphases for safe initialization.
Add the following dependency to your pom.xml:
<dependency>
<groupId>com.guicedee</groupId>
<artifactId>guiced-health</artifactId>
</dependency>Use the @HealthOptions annotation on your application class or package to customize the health check behavior.
@HealthOptions(
enabled = true,
path = "/health",
livenessPath = "/health/live",
readinessPath = "/health/ready",
startupPath = "/health/started"
)
public class MyConfiguration {
}| Attribute | Default Value | Description |
|---|---|---|
enabled |
true |
Enables or disables the health check module. |
path |
/health |
Path for the aggregated health status. |
livenessPath |
/health/live |
Path for liveness checks. |
readinessPath |
/health/ready |
Path for readiness checks. |
startupPath |
/health/started |
Path for startup checks. |
Implement the org.eclipse.microprofile.health.HealthCheck interface and annotate it with the appropriate scope.
Liveness checks determine if the application is running correctly.
import org.eclipse.microprofile.health.HealthCheck;
import org.eclipse.microprofile.health.HealthCheckResponse;
import org.eclipse.microprofile.health.Liveness;
@Liveness
public class DatabaseLiveness implements HealthCheck {
@Override
public HealthCheckResponse call() {
return HealthCheckResponse.named("DatabaseLiveness")
.up()
.withData("connection", "stable")
.build();
}
}Readiness checks determine if the application is ready to process requests.
import org.eclipse.microprofile.health.HealthCheck;
import org.eclipse.microprofile.health.HealthCheckResponse;
import org.eclipse.microprofile.health.Readiness;
@Readiness
public class ServiceReadiness implements HealthCheck {
@Override
public HealthCheckResponse call() {
return HealthCheckResponse.named("ServiceReadiness")
.up()
.build();
}
}Startup checks verify if the application has finished its initialization.
import org.eclipse.microprofile.health.HealthCheck;
import org.eclipse.microprofile.health.HealthCheckResponse;
import org.eclipse.microprofile.health.Startup;
@Startup
public class InitializerStartup implements HealthCheck {
@Override
public HealthCheckResponse call() {
return HealthCheckResponse.named("InitializerStartup")
.up()
.build();
}
}If you need to register health checks manually using the Vert.x API, you can inject the HealthChecks instance:
import io.vertx.ext.healthchecks.HealthChecks;
import io.vertx.ext.healthchecks.Status;
import com.google.inject.Inject;
public class MyService {
@Inject
public MyService(HealthChecks hc) {
hc.register("my-check", promise -> promise.complete(Status.OK()));
}
}- Rules:
RULES.md - Guides:
GUIDES.md
Contributions are welcome! Please follow the existing code style and ensure all tests pass before submitting a PR.
This project is licensed under the terms of the Apache License, Version 2.0.