Skip to content

Commit

Permalink
Use AbstractHealthCheck for custom health checks
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesnetherton committed Mar 23, 2021
1 parent fef8c31 commit ab75b93
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ Check the xref:user-guide/index.adoc[User guide] for more information about writ

You can register health checks for your applications with the xref:latest@manual::health-check.adoc[Camel health check API].

By default, classes extending `AbstractHealthCheck` are registered as both liveness and readiness checks. For finer control over whether
a check is registered as a liveness or readiness check, you can extend either `AbstractCamelMicroProfileLivenessCheck` or `AbstractCamelMicroProfileReadinessCheck`.
By default, classes extending `AbstractHealthCheck` are registered as both liveness and readiness checks. You can override the `isReadiness` method to control this behaviour.

Any checks provided by your application are automatically discovered and bound to the Camel registry. They will be available via
the Quarkus health endpoints `/health/live` and `/health/ready`.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
You can register health checks for your applications with the xref:latest@manual::health-check.adoc[Camel health check API].

By default, classes extending `AbstractHealthCheck` are registered as both liveness and readiness checks. For finer control over whether
a check is registered as a liveness or readiness check, you can extend either `AbstractCamelMicroProfileLivenessCheck` or `AbstractCamelMicroProfileReadinessCheck`.
By default, classes extending `AbstractHealthCheck` are registered as both liveness and readiness checks. You can override the `isReadiness` method to control this behaviour.

Any checks provided by your application are automatically discovered and bound to the Camel registry. They will be available via
the Quarkus health endpoints `/health/live` and `/health/ready`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
import java.util.Map;

import org.apache.camel.health.HealthCheckResultBuilder;
import org.apache.camel.microprofile.health.AbstractCamelMicroProfileLivenessCheck;
import org.apache.camel.impl.health.AbstractHealthCheck;

public class LivenessCheck extends AbstractCamelMicroProfileLivenessCheck {
public class LivenessCheck extends AbstractHealthCheck {

public LivenessCheck() {
super("test-liveness");
Expand All @@ -31,4 +31,9 @@ public LivenessCheck() {
protected void doCall(HealthCheckResultBuilder builder, Map<String, Object> options) {
builder.up();
}

@Override
public boolean isReadiness() {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
import java.util.Map;

import org.apache.camel.health.HealthCheckResultBuilder;
import org.apache.camel.microprofile.health.AbstractCamelMicroProfileReadinessCheck;
import org.apache.camel.impl.health.AbstractHealthCheck;

public class ReadinessCheck extends AbstractCamelMicroProfileReadinessCheck {
public class ReadinessCheck extends AbstractHealthCheck {

public ReadinessCheck() {
super("test-readiness");
Expand All @@ -31,4 +31,9 @@ public ReadinessCheck() {
protected void doCall(HealthCheckResultBuilder builder, Map<String, Object> options) {
builder.up();
}

@Override
public boolean isLiveness() {
return false;
}
}

0 comments on commit ab75b93

Please sign in to comment.