This is an automated email from the ASF dual-hosted git repository. jamesnetherton pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel-quarkus-examples.git
The following commit(s) were added to refs/heads/master by this push: new 6b6f5eb Use AbstractHealthCheck for custom health checks 6b6f5eb is described below commit 6b6f5eb106648b52357bcddaf92552ea4767f0a5 Author: James Netherton <jamesnether...@gmail.com> AuthorDate: Tue Mar 23 14:59:32 2021 +0000 Use AbstractHealthCheck for custom health checks --- observability/README.adoc | 2 +- .../org/acme/observability/health/camel/CustomLivenessCheck.java | 9 +++++++-- .../acme/observability/health/camel/CustomReadinessCheck.java | 9 +++++++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/observability/README.adoc b/observability/README.adoc index 68099d9..759bf4a 100644 --- a/observability/README.adoc +++ b/observability/README.adoc @@ -56,7 +56,7 @@ $ curl -s localhost:8080/health/ready The JSON output will contain a check named 'camel' for verifying whether the `CamelContext` is in the 'Started' state and another check to verify whether each individual route is in the 'Started' state. This example project contains a custom liveness check class `CustomLivenessCheck` and custom readiness check class `CustomReadinessCheck` which leverage the Camel health API. -You'll see these listed in the health JSON as 'custom-liveness-check' and 'custom-readiness-check'. On every 5th invocation of these checks, the health status will be reported as DOWN. +You'll see these listed in the health JSON as 'custom-liveness-check' and 'custom-readiness-check'. On every 5th invocation of these checks, the health status of `custom-liveness-check` will be reported as DOWN. You can also directly leverage MicroProfile Metrics APIs to create checks. Class `CamelUptimeHealthCheck` demonstrates how to register a readiness check. diff --git a/observability/src/main/java/org/acme/observability/health/camel/CustomLivenessCheck.java b/observability/src/main/java/org/acme/observability/health/camel/CustomLivenessCheck.java index 0d380d1..98b81f8 100644 --- a/observability/src/main/java/org/acme/observability/health/camel/CustomLivenessCheck.java +++ b/observability/src/main/java/org/acme/observability/health/camel/CustomLivenessCheck.java @@ -20,14 +20,14 @@ import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; import org.apache.camel.health.HealthCheckResultBuilder; -import org.apache.camel.microprofile.health.AbstractCamelMicroProfileLivenessCheck; +import org.apache.camel.impl.health.AbstractHealthCheck; /** * A simple custom liveness check which utilizes the Camel Health API. * * The check status is recorded as DOWN on every 5th invocation. */ -public class CustomLivenessCheck extends AbstractCamelMicroProfileLivenessCheck { +public class CustomLivenessCheck extends AbstractHealthCheck { AtomicInteger hitCount = new AtomicInteger(); @@ -47,4 +47,9 @@ public class CustomLivenessCheck extends AbstractCamelMicroProfileLivenessCheck builder.up(); } } + + @Override + public boolean isReadiness() { + return false; + } } diff --git a/observability/src/main/java/org/acme/observability/health/camel/CustomReadinessCheck.java b/observability/src/main/java/org/acme/observability/health/camel/CustomReadinessCheck.java index 9ebe412..8f3e27d 100644 --- a/observability/src/main/java/org/acme/observability/health/camel/CustomReadinessCheck.java +++ b/observability/src/main/java/org/acme/observability/health/camel/CustomReadinessCheck.java @@ -19,12 +19,12 @@ package org.acme.observability.health.camel; import java.util.Map; import org.apache.camel.health.HealthCheckResultBuilder; -import org.apache.camel.microprofile.health.AbstractCamelMicroProfileReadinessCheck; +import org.apache.camel.impl.health.AbstractHealthCheck; /** * A simple custom liveness check which utilizes the Camel Health API. */ -public class CustomReadinessCheck extends AbstractCamelMicroProfileReadinessCheck { +public class CustomReadinessCheck extends AbstractHealthCheck { public CustomReadinessCheck() { super("custom-readiness-check"); @@ -35,4 +35,9 @@ public class CustomReadinessCheck extends AbstractCamelMicroProfileReadinessChec protected void doCall(HealthCheckResultBuilder builder, Map<String, Object> options) { builder.up(); } + + @Override + public boolean isLiveness() { + return false; + } }