You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2023/07/28 08:22:30 UTC

[camel] 02/13: CAMEL-19645: camel-aws - producer health check

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch hc-producer
in repository https://gitbox.apache.org/repos/asf/camel.git

commit b2d651850982f7282784391f177a804a17da613c
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri Jul 28 09:45:02 2023 +0200

    CAMEL-19645: camel-aws - producer health check
---
 .../component/aws2/athena/Athena2Producer.java     |  8 +++---
 .../component/aws2/cw/Cw2ComponentConfigurer.java  | 18 +++++++++++++
 .../apache/camel/component/aws2/cw/aws2-cw.json    |  7 +++--
 .../camel/component/aws2/cw/Cw2Component.java      |  4 +--
 .../camel/component/aws2/cw/Cw2Endpoint.java       | 23 ++++------------
 .../camel/component/aws2/cw/Cw2Producer.java       | 31 ++++++++++++++++++++++
 ...ealthCheck.java => Cw2ProducerHealthCheck.java} |  6 ++---
 .../aws2/ddb/Ddb2ComponentConfigurer.java          | 18 +++++++++++++
 .../apache/camel/component/aws2/ddb/aws2-ddb.json  |  7 +++--
 .../aws2/ddb/Db2ProducerHealthCheck.java}          | 25 +++++++++--------
 .../camel/component/aws2/ddb/Ddb2Component.java    |  5 ++--
 .../camel/component/aws2/ddb/Ddb2Endpoint.java     |  5 ++++
 .../camel/component/aws2/ddb/Ddb2Producer.java     | 31 ++++++++++++++++++++++
 ...> Ddb2ProducerHealthCheckProfileCredsTest.java} | 12 ++-------
 ...=> Ddb2ProducerHealthCheckStaticCredsTest.java} | 12 ++-------
 15 files changed, 145 insertions(+), 67 deletions(-)

diff --git a/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/Athena2Producer.java b/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/Athena2Producer.java
index 3e5294442ad..7b67c5d50b3 100644
--- a/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/Athena2Producer.java
+++ b/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/Athena2Producer.java
@@ -21,6 +21,7 @@ import java.util.Arrays;
 import org.apache.camel.Endpoint;
 import org.apache.camel.Exchange;
 import org.apache.camel.Message;
+import org.apache.camel.health.HealthCheck;
 import org.apache.camel.health.HealthCheckHelper;
 import org.apache.camel.health.WritableHealthCheckRepository;
 import org.apache.camel.support.DefaultProducer;
@@ -49,7 +50,7 @@ public class Athena2Producer extends DefaultProducer {
 
     private static final Logger LOG = LoggerFactory.getLogger(Athena2Producer.class);
 
-    private Athena2ProducerHealthCheck producerHealthCheck;
+    private HealthCheck producerHealthCheck;
     private WritableHealthCheckRepository healthCheckRepository;
 
     public Athena2Producer(Endpoint endpoint) {
@@ -441,10 +442,7 @@ public class Athena2Producer extends DefaultProducer {
                 WritableHealthCheckRepository.class);
 
         if (healthCheckRepository != null) {
-            String id = getEndpoint().getConfiguration().getQueryExecutionId();
-            if (id == null) {
-                id = getEndpoint().getId();
-            }
+            String id = getEndpoint().getId();
             producerHealthCheck = new Athena2ProducerHealthCheck(getEndpoint(), id);
             producerHealthCheck.setEnabled(getEndpoint().getComponent().isHealthCheckEnabled()
                     && getEndpoint().getComponent().isHealthCheckProducerEnabled());
diff --git a/components/camel-aws/camel-aws2-cw/src/generated/java/org/apache/camel/component/aws2/cw/Cw2ComponentConfigurer.java b/components/camel-aws/camel-aws2-cw/src/generated/java/org/apache/camel/component/aws2/cw/Cw2ComponentConfigurer.java
index d7a831d02bf..ddc48637431 100644
--- a/components/camel-aws/camel-aws2-cw/src/generated/java/org/apache/camel/component/aws2/cw/Cw2ComponentConfigurer.java
+++ b/components/camel-aws/camel-aws2-cw/src/generated/java/org/apache/camel/component/aws2/cw/Cw2ComponentConfigurer.java
@@ -35,6 +35,12 @@ public class Cw2ComponentConfigurer extends PropertyConfigurerSupport implements
         case "autowiredenabled":
         case "autowiredEnabled": target.setAutowiredEnabled(property(camelContext, boolean.class, value)); return true;
         case "configuration": target.setConfiguration(property(camelContext, org.apache.camel.component.aws2.cw.Cw2Configuration.class, value)); return true;
+        case "healthcheckconsumerenabled":
+        case "healthCheckConsumerEnabled": target.setHealthCheckConsumerEnabled(property(camelContext, boolean.class, value)); return true;
+        case "healthcheckenabled":
+        case "healthCheckEnabled": target.setHealthCheckEnabled(property(camelContext, boolean.class, value)); return true;
+        case "healthcheckproducerenabled":
+        case "healthCheckProducerEnabled": target.setHealthCheckProducerEnabled(property(camelContext, boolean.class, value)); return true;
         case "lazystartproducer":
         case "lazyStartProducer": target.setLazyStartProducer(property(camelContext, boolean.class, value)); return true;
         case "name": getOrCreateConfiguration(target).setName(property(camelContext, java.lang.String.class, value)); return true;
@@ -81,6 +87,12 @@ public class Cw2ComponentConfigurer extends PropertyConfigurerSupport implements
         case "autowiredenabled":
         case "autowiredEnabled": return boolean.class;
         case "configuration": return org.apache.camel.component.aws2.cw.Cw2Configuration.class;
+        case "healthcheckconsumerenabled":
+        case "healthCheckConsumerEnabled": return boolean.class;
+        case "healthcheckenabled":
+        case "healthCheckEnabled": return boolean.class;
+        case "healthcheckproducerenabled":
+        case "healthCheckProducerEnabled": return boolean.class;
         case "lazystartproducer":
         case "lazyStartProducer": return boolean.class;
         case "name": return java.lang.String.class;
@@ -123,6 +135,12 @@ public class Cw2ComponentConfigurer extends PropertyConfigurerSupport implements
         case "autowiredenabled":
         case "autowiredEnabled": return target.isAutowiredEnabled();
         case "configuration": return target.getConfiguration();
+        case "healthcheckconsumerenabled":
+        case "healthCheckConsumerEnabled": return target.isHealthCheckConsumerEnabled();
+        case "healthcheckenabled":
+        case "healthCheckEnabled": return target.isHealthCheckEnabled();
+        case "healthcheckproducerenabled":
+        case "healthCheckProducerEnabled": return target.isHealthCheckProducerEnabled();
         case "lazystartproducer":
         case "lazyStartProducer": return target.isLazyStartProducer();
         case "name": return getOrCreateConfiguration(target).getName();
diff --git a/components/camel-aws/camel-aws2-cw/src/generated/resources/org/apache/camel/component/aws2/cw/aws2-cw.json b/components/camel-aws/camel-aws2-cw/src/generated/resources/org/apache/camel/component/aws2/cw/aws2-cw.json
index 51ee300af56..212d6245ee4 100644
--- a/components/camel-aws/camel-aws2-cw/src/generated/resources/org/apache/camel/component/aws2/cw/aws2-cw.json
+++ b/components/camel-aws/camel-aws2-cw/src/generated/resources/org/apache/camel/component/aws2/cw/aws2-cw.json
@@ -40,8 +40,11 @@
     "useProfileCredentialsProvider": { "index": 15, "kind": "property", "displayName": "Use Profile Credentials Provider", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.cw.Cw2Configuration", "configurationField": "configuration", "description": "Set whether the Cloudwatch client should expect to load crede [...]
     "value": { "index": 16, "kind": "property", "displayName": "Value", "group": "producer", "label": "", "required": false, "type": "number", "javaType": "java.lang.Double", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.cw.Cw2Configuration", "configurationField": "configuration", "description": "The metric value" },
     "autowiredEnabled": { "index": 17, "kind": "property", "displayName": "Autowired Enabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching  [...]
-    "accessKey": { "index": 18, "kind": "property", "displayName": "Access Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws2.cw.Cw2Configuration", "configurationField": "configuration", "description": "Amazon AWS Access Key" },
-    "secretKey": { "index": 19, "kind": "property", "displayName": "Secret Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws2.cw.Cw2Configuration", "configurationField": "configuration", "description": "Amazon AWS Secret Key" }
+    "healthCheckConsumerEnabled": { "index": 18, "kind": "property", "displayName": "Health Check Consumer Enabled", "group": "health", "label": "health", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Used for enabling or disabling all consumer based health checks from this component" },
+    "healthCheckEnabled": { "index": 19, "kind": "property", "displayName": "Health Check Enabled", "group": "health", "label": "health", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Used for enabling or disabling all health checks from this component" },
+    "healthCheckProducerEnabled": { "index": 20, "kind": "property", "displayName": "Health Check Producer Enabled", "group": "health", "label": "health", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Used for enabling or disabling all producer based health checks from this component" },
+    "accessKey": { "index": 21, "kind": "property", "displayName": "Access Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws2.cw.Cw2Configuration", "configurationField": "configuration", "description": "Amazon AWS Access Key" },
+    "secretKey": { "index": 22, "kind": "property", "displayName": "Secret Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws2.cw.Cw2Configuration", "configurationField": "configuration", "description": "Amazon AWS Secret Key" }
   },
   "headers": {
     "CamelAwsCwMetricNamespace": { "index": 0, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The Amazon CW metric namespace.", "constantName": "org.apache.camel.component.aws2.cw.Cw2Constants#METRIC_NAMESPACE" },
diff --git a/components/camel-aws/camel-aws2-cw/src/main/java/org/apache/camel/component/aws2/cw/Cw2Component.java b/components/camel-aws/camel-aws2-cw/src/main/java/org/apache/camel/component/aws2/cw/Cw2Component.java
index a5712bb7636..b09d069979c 100644
--- a/components/camel-aws/camel-aws2-cw/src/main/java/org/apache/camel/component/aws2/cw/Cw2Component.java
+++ b/components/camel-aws/camel-aws2-cw/src/main/java/org/apache/camel/component/aws2/cw/Cw2Component.java
@@ -22,13 +22,13 @@ import org.apache.camel.CamelContext;
 import org.apache.camel.Endpoint;
 import org.apache.camel.spi.Metadata;
 import org.apache.camel.spi.annotations.Component;
-import org.apache.camel.support.DefaultComponent;
+import org.apache.camel.support.HealthCheckComponent;
 
 /**
  * For working with Amazon CloudWatch SDK v2.
  */
 @Component("aws2-cw")
-public class Cw2Component extends DefaultComponent {
+public class Cw2Component extends HealthCheckComponent {
 
     @Metadata
     private Cw2Configuration configuration = new Cw2Configuration();
diff --git a/components/camel-aws/camel-aws2-cw/src/main/java/org/apache/camel/component/aws2/cw/Cw2Endpoint.java b/components/camel-aws/camel-aws2-cw/src/main/java/org/apache/camel/component/aws2/cw/Cw2Endpoint.java
index 2686a48260b..8f30ff24b7b 100644
--- a/components/camel-aws/camel-aws2-cw/src/main/java/org/apache/camel/component/aws2/cw/Cw2Endpoint.java
+++ b/components/camel-aws/camel-aws2-cw/src/main/java/org/apache/camel/component/aws2/cw/Cw2Endpoint.java
@@ -22,8 +22,6 @@ import org.apache.camel.Consumer;
 import org.apache.camel.Processor;
 import org.apache.camel.Producer;
 import org.apache.camel.component.aws2.cw.client.Cw2ClientFactory;
-import org.apache.camel.health.HealthCheckHelper;
-import org.apache.camel.impl.health.ComponentsHealthCheckRepository;
 import org.apache.camel.spi.UriEndpoint;
 import org.apache.camel.spi.UriParam;
 import org.apache.camel.support.DefaultEndpoint;
@@ -40,14 +38,17 @@ public class Cw2Endpoint extends DefaultEndpoint {
     @UriParam
     private Cw2Configuration configuration;
     private CloudWatchClient cloudWatchClient;
-    private ComponentsHealthCheckRepository healthCheckRepository;
-    private Cw2ClientHealthCheck clientHealthCheck;
 
     public Cw2Endpoint(String uri, Component component, Cw2Configuration configuration) {
         super(uri, component);
         this.configuration = configuration;
     }
 
+    @Override
+    public Cw2Component getComponent() {
+        return (Cw2Component) super.getComponent();
+    }
+
     @Override
     public Consumer createConsumer(Processor processor) throws Exception {
         throw new UnsupportedOperationException("You cannot receive messages from this endpoint");
@@ -76,20 +77,6 @@ public class Cw2Endpoint extends DefaultEndpoint {
         super.doStop();
     }
 
-    @Override
-    public void doStart() throws Exception {
-        super.doStart();
-
-        healthCheckRepository = HealthCheckHelper.getHealthCheckRepository(getCamelContext(),
-                ComponentsHealthCheckRepository.REPOSITORY_ID, ComponentsHealthCheckRepository.class);
-
-        if (healthCheckRepository != null) {
-            // Do not register the health check until we resolve CAMEL-18992
-            //clientHealthCheck = new Cw2ClientHealthCheck(this, getId());
-            //healthCheckRepository.addHealthCheck(clientHealthCheck);
-        }
-    }
-
     public Cw2Configuration getConfiguration() {
         return configuration;
     }
diff --git a/components/camel-aws/camel-aws2-cw/src/main/java/org/apache/camel/component/aws2/cw/Cw2Producer.java b/components/camel-aws/camel-aws2-cw/src/main/java/org/apache/camel/component/aws2/cw/Cw2Producer.java
index 01954efd80b..4dc6afd5cfa 100644
--- a/components/camel-aws/camel-aws2-cw/src/main/java/org/apache/camel/component/aws2/cw/Cw2Producer.java
+++ b/components/camel-aws/camel-aws2-cw/src/main/java/org/apache/camel/component/aws2/cw/Cw2Producer.java
@@ -25,6 +25,9 @@ import java.util.Map;
 
 import org.apache.camel.Endpoint;
 import org.apache.camel.Exchange;
+import org.apache.camel.health.HealthCheck;
+import org.apache.camel.health.HealthCheckHelper;
+import org.apache.camel.health.WritableHealthCheckRepository;
 import org.apache.camel.support.DefaultProducer;
 import org.apache.camel.util.CastUtils;
 import org.apache.camel.util.URISupport;
@@ -42,6 +45,8 @@ public class Cw2Producer extends DefaultProducer {
 
     private static final Logger LOG = LoggerFactory.getLogger(Cw2Producer.class);
 
+    private HealthCheck producerHealthCheck;
+    private WritableHealthCheckRepository healthCheckRepository;
     private transient String cwProducerToString;
 
     public Cw2Producer(Endpoint endpoint) {
@@ -153,4 +158,30 @@ public class Cw2Producer extends DefaultProducer {
     public Cw2Endpoint getEndpoint() {
         return (Cw2Endpoint) super.getEndpoint();
     }
+
+    @Override
+    protected void doStart() throws Exception {
+        // health-check is optional so discover and resolve
+        healthCheckRepository = HealthCheckHelper.getHealthCheckRepository(
+                getEndpoint().getCamelContext(),
+                "components",
+                WritableHealthCheckRepository.class);
+
+        if (healthCheckRepository != null) {
+            String id = getEndpoint().getId();
+            producerHealthCheck = new Cw2ProducerHealthCheck(getEndpoint(), id);
+            producerHealthCheck.setEnabled(getEndpoint().getComponent().isHealthCheckEnabled()
+                                           && getEndpoint().getComponent().isHealthCheckProducerEnabled());
+            healthCheckRepository.addHealthCheck(producerHealthCheck);
+        }
+    }
+
+    @Override
+    protected void doStop() throws Exception {
+        if (healthCheckRepository != null && producerHealthCheck != null) {
+            healthCheckRepository.removeHealthCheck(producerHealthCheck);
+            producerHealthCheck = null;
+        }
+    }
+
 }
diff --git a/components/camel-aws/camel-aws2-cw/src/main/java/org/apache/camel/component/aws2/cw/Cw2ClientHealthCheck.java b/components/camel-aws/camel-aws2-cw/src/main/java/org/apache/camel/component/aws2/cw/Cw2ProducerHealthCheck.java
similarity index 93%
copy from components/camel-aws/camel-aws2-cw/src/main/java/org/apache/camel/component/aws2/cw/Cw2ClientHealthCheck.java
copy to components/camel-aws/camel-aws2-cw/src/main/java/org/apache/camel/component/aws2/cw/Cw2ProducerHealthCheck.java
index a8dc3b8deb7..e5f1c5f6751 100644
--- a/components/camel-aws/camel-aws2-cw/src/main/java/org/apache/camel/component/aws2/cw/Cw2ClientHealthCheck.java
+++ b/components/camel-aws/camel-aws2-cw/src/main/java/org/apache/camel/component/aws2/cw/Cw2ProducerHealthCheck.java
@@ -27,12 +27,12 @@ import software.amazon.awssdk.regions.Region;
 import software.amazon.awssdk.services.cloudwatch.CloudWatchClient;
 import software.amazon.awssdk.services.cloudwatch.model.ListDashboardsRequest;
 
-public class Cw2ClientHealthCheck extends AbstractHealthCheck {
+public class Cw2ProducerHealthCheck extends AbstractHealthCheck {
 
     private final Cw2Endpoint cw2Endpoint;
 
-    public Cw2ClientHealthCheck(Cw2Endpoint cw2Endpoint, String clientId) {
-        super("camel", "aws2-cw-client-" + clientId);
+    public Cw2ProducerHealthCheck(Cw2Endpoint cw2Endpoint, String clientId) {
+        super("camel", "aws2-cw-producer-" + clientId);
         this.cw2Endpoint = cw2Endpoint;
     }
 
diff --git a/components/camel-aws/camel-aws2-ddb/src/generated/java/org/apache/camel/component/aws2/ddb/Ddb2ComponentConfigurer.java b/components/camel-aws/camel-aws2-ddb/src/generated/java/org/apache/camel/component/aws2/ddb/Ddb2ComponentConfigurer.java
index 1f7c1ac9002..2b5fb38dd50 100644
--- a/components/camel-aws/camel-aws2-ddb/src/generated/java/org/apache/camel/component/aws2/ddb/Ddb2ComponentConfigurer.java
+++ b/components/camel-aws/camel-aws2-ddb/src/generated/java/org/apache/camel/component/aws2/ddb/Ddb2ComponentConfigurer.java
@@ -39,6 +39,12 @@ public class Ddb2ComponentConfigurer extends PropertyConfigurerSupport implement
         case "consistentRead": getOrCreateConfiguration(target).setConsistentRead(property(camelContext, boolean.class, value)); return true;
         case "enabledinitialdescribetable":
         case "enabledInitialDescribeTable": getOrCreateConfiguration(target).setEnabledInitialDescribeTable(property(camelContext, boolean.class, value)); return true;
+        case "healthcheckconsumerenabled":
+        case "healthCheckConsumerEnabled": target.setHealthCheckConsumerEnabled(property(camelContext, boolean.class, value)); return true;
+        case "healthcheckenabled":
+        case "healthCheckEnabled": target.setHealthCheckEnabled(property(camelContext, boolean.class, value)); return true;
+        case "healthcheckproducerenabled":
+        case "healthCheckProducerEnabled": target.setHealthCheckProducerEnabled(property(camelContext, boolean.class, value)); return true;
         case "keyattributename":
         case "keyAttributeName": getOrCreateConfiguration(target).setKeyAttributeName(property(camelContext, java.lang.String.class, value)); return true;
         case "keyattributetype":
@@ -96,6 +102,12 @@ public class Ddb2ComponentConfigurer extends PropertyConfigurerSupport implement
         case "consistentRead": return boolean.class;
         case "enabledinitialdescribetable":
         case "enabledInitialDescribeTable": return boolean.class;
+        case "healthcheckconsumerenabled":
+        case "healthCheckConsumerEnabled": return boolean.class;
+        case "healthcheckenabled":
+        case "healthCheckEnabled": return boolean.class;
+        case "healthcheckproducerenabled":
+        case "healthCheckProducerEnabled": return boolean.class;
         case "keyattributename":
         case "keyAttributeName": return java.lang.String.class;
         case "keyattributetype":
@@ -149,6 +161,12 @@ public class Ddb2ComponentConfigurer extends PropertyConfigurerSupport implement
         case "consistentRead": return getOrCreateConfiguration(target).isConsistentRead();
         case "enabledinitialdescribetable":
         case "enabledInitialDescribeTable": return getOrCreateConfiguration(target).isEnabledInitialDescribeTable();
+        case "healthcheckconsumerenabled":
+        case "healthCheckConsumerEnabled": return target.isHealthCheckConsumerEnabled();
+        case "healthcheckenabled":
+        case "healthCheckEnabled": return target.isHealthCheckEnabled();
+        case "healthcheckproducerenabled":
+        case "healthCheckProducerEnabled": return target.isHealthCheckProducerEnabled();
         case "keyattributename":
         case "keyAttributeName": return getOrCreateConfiguration(target).getKeyAttributeName();
         case "keyattributetype":
diff --git a/components/camel-aws/camel-aws2-ddb/src/generated/resources/org/apache/camel/component/aws2/ddb/aws2-ddb.json b/components/camel-aws/camel-aws2-ddb/src/generated/resources/org/apache/camel/component/aws2/ddb/aws2-ddb.json
index c41957010e9..9f50f17e306 100644
--- a/components/camel-aws/camel-aws2-ddb/src/generated/resources/org/apache/camel/component/aws2/ddb/aws2-ddb.json
+++ b/components/camel-aws/camel-aws2-ddb/src/generated/resources/org/apache/camel/component/aws2/ddb/aws2-ddb.json
@@ -44,8 +44,11 @@
     "useProfileCredentialsProvider": { "index": 19, "kind": "property", "displayName": "Use Profile Credentials Provider", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.ddb.Ddb2Configuration", "configurationField": "configuration", "description": "Set whether the DDB client should expect to load credential [...]
     "writeCapacity": { "index": 20, "kind": "property", "displayName": "Write Capacity", "group": "producer", "label": "", "required": false, "type": "integer", "javaType": "java.lang.Long", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.ddb.Ddb2Configuration", "configurationField": "configuration", "description": "The provisioned throughput to reserved for writing resources to your table" },
     "autowiredEnabled": { "index": 21, "kind": "property", "displayName": "Autowired Enabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching  [...]
-    "accessKey": { "index": 22, "kind": "property", "displayName": "Access Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws2.ddb.Ddb2Configuration", "configurationField": "configuration", "description": "Amazon AWS Access Key" },
-    "secretKey": { "index": 23, "kind": "property", "displayName": "Secret Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws2.ddb.Ddb2Configuration", "configurationField": "configuration", "description": "Amazon AWS Secret Key" }
+    "healthCheckConsumerEnabled": { "index": 22, "kind": "property", "displayName": "Health Check Consumer Enabled", "group": "health", "label": "health", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Used for enabling or disabling all consumer based health checks from this component" },
+    "healthCheckEnabled": { "index": 23, "kind": "property", "displayName": "Health Check Enabled", "group": "health", "label": "health", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Used for enabling or disabling all health checks from this component" },
+    "healthCheckProducerEnabled": { "index": 24, "kind": "property", "displayName": "Health Check Producer Enabled", "group": "health", "label": "health", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Used for enabling or disabling all producer based health checks from this component" },
+    "accessKey": { "index": 25, "kind": "property", "displayName": "Access Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws2.ddb.Ddb2Configuration", "configurationField": "configuration", "description": "Amazon AWS Access Key" },
+    "secretKey": { "index": 26, "kind": "property", "displayName": "Secret Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws2.ddb.Ddb2Configuration", "configurationField": "configuration", "description": "Amazon AWS Secret Key" }
   },
   "headers": {
     "CamelAwsDdbAttributes": { "index": 0, "kind": "header", "displayName": "", "group": "DeleteItem GetItem PutItem UpdateItem", "label": "DeleteItem GetItem PutItem UpdateItem", "required": false, "javaType": "Map<String, AttributeValue>", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The list of attributes returned by the operation.", "constantName": "org.apache.camel.component.aws2.ddb.Ddb2Constants#ATTRIBUTES" },
diff --git a/components/camel-aws/camel-aws2-cw/src/main/java/org/apache/camel/component/aws2/cw/Cw2ClientHealthCheck.java b/components/camel-aws/camel-aws2-ddb/src/main/java/org/apache/camel/component/aws2/ddb/Db2ProducerHealthCheck.java
similarity index 72%
rename from components/camel-aws/camel-aws2-cw/src/main/java/org/apache/camel/component/aws2/cw/Cw2ClientHealthCheck.java
rename to components/camel-aws/camel-aws2-ddb/src/main/java/org/apache/camel/component/aws2/ddb/Db2ProducerHealthCheck.java
index a8dc3b8deb7..6e1b2b624f3 100644
--- a/components/camel-aws/camel-aws2-cw/src/main/java/org/apache/camel/component/aws2/cw/Cw2ClientHealthCheck.java
+++ b/components/camel-aws/camel-aws2-ddb/src/main/java/org/apache/camel/component/aws2/ddb/Db2ProducerHealthCheck.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.camel.component.aws2.cw;
+package org.apache.camel.component.aws2.ddb;
 
 import java.util.Map;
 
@@ -24,31 +24,31 @@ import org.apache.camel.impl.health.AbstractHealthCheck;
 import org.apache.camel.util.ObjectHelper;
 import software.amazon.awssdk.awscore.exception.AwsServiceException;
 import software.amazon.awssdk.regions.Region;
-import software.amazon.awssdk.services.cloudwatch.CloudWatchClient;
-import software.amazon.awssdk.services.cloudwatch.model.ListDashboardsRequest;
+import software.amazon.awssdk.services.dynamodb.DynamoDbClient;
+import software.amazon.awssdk.services.dynamodb.model.ListTablesRequest;
 
-public class Cw2ClientHealthCheck extends AbstractHealthCheck {
+public class Db2ProducerHealthCheck extends AbstractHealthCheck {
 
-    private final Cw2Endpoint cw2Endpoint;
+    private final Ddb2Endpoint ddb2Endpoint;
 
-    public Cw2ClientHealthCheck(Cw2Endpoint cw2Endpoint, String clientId) {
-        super("camel", "aws2-cw-client-" + clientId);
-        this.cw2Endpoint = cw2Endpoint;
+    public Db2ProducerHealthCheck(Ddb2Endpoint ddb2Endpoint, String clientId) {
+        super("camel", "aws2-ddb-producer-" + clientId);
+        this.ddb2Endpoint = ddb2Endpoint;
     }
 
     @Override
     protected void doCall(HealthCheckResultBuilder builder, Map<String, Object> options) {
-        Cw2Configuration configuration = cw2Endpoint.getConfiguration();
+        Ddb2Configuration configuration = ddb2Endpoint.getConfiguration();
         if (ObjectHelper.isNotEmpty(configuration.getRegion())) {
-            if (!CloudWatchClient.serviceMetadata().regions().contains(Region.of(configuration.getRegion()))) {
+            if (!DynamoDbClient.serviceMetadata().regions().contains(Region.of(configuration.getRegion()))) {
                 builder.message("The service is not supported in this region");
                 builder.down();
                 return;
             }
         }
         try {
-            CloudWatchClient cw2Client = cw2Endpoint.getCloudWatchClient();
-            cw2Client.listDashboards(ListDashboardsRequest.builder().build());
+            DynamoDbClient ddbClient = ddb2Endpoint.getDdbClient();
+            ddbClient.listTables(ListTablesRequest.builder().limit(1).build());
         } catch (AwsServiceException e) {
             builder.message(e.getMessage());
             builder.error(e);
@@ -67,5 +67,4 @@ public class Cw2ClientHealthCheck extends AbstractHealthCheck {
         }
         builder.up();
     }
-
 }
diff --git a/components/camel-aws/camel-aws2-ddb/src/main/java/org/apache/camel/component/aws2/ddb/Ddb2Component.java b/components/camel-aws/camel-aws2-ddb/src/main/java/org/apache/camel/component/aws2/ddb/Ddb2Component.java
index 7c898af6735..d62eb17682d 100644
--- a/components/camel-aws/camel-aws2-ddb/src/main/java/org/apache/camel/component/aws2/ddb/Ddb2Component.java
+++ b/components/camel-aws/camel-aws2-ddb/src/main/java/org/apache/camel/component/aws2/ddb/Ddb2Component.java
@@ -22,10 +22,11 @@ import org.apache.camel.CamelContext;
 import org.apache.camel.Endpoint;
 import org.apache.camel.spi.Metadata;
 import org.apache.camel.spi.annotations.Component;
-import org.apache.camel.support.DefaultComponent;
+import org.apache.camel.support.HealthCheckComponent;
 
 @Component("aws2-ddb")
-public class Ddb2Component extends DefaultComponent {
+public class Ddb2Component extends HealthCheckComponent {
+
     @Metadata
     private Ddb2Configuration configuration = new Ddb2Configuration();
 
diff --git a/components/camel-aws/camel-aws2-ddb/src/main/java/org/apache/camel/component/aws2/ddb/Ddb2Endpoint.java b/components/camel-aws/camel-aws2-ddb/src/main/java/org/apache/camel/component/aws2/ddb/Ddb2Endpoint.java
index 9bac3d87e64..f0f97423206 100644
--- a/components/camel-aws/camel-aws2-ddb/src/main/java/org/apache/camel/component/aws2/ddb/Ddb2Endpoint.java
+++ b/components/camel-aws/camel-aws2-ddb/src/main/java/org/apache/camel/component/aws2/ddb/Ddb2Endpoint.java
@@ -76,6 +76,11 @@ public class Ddb2Endpoint extends ScheduledPollEndpoint {
         return new Ddb2Producer(this);
     }
 
+    @Override
+    public Ddb2Component getComponent() {
+        return (Ddb2Component) super.getComponent();
+    }
+
     @Override
     public void doStart() throws Exception {
         super.doStart();
diff --git a/components/camel-aws/camel-aws2-ddb/src/main/java/org/apache/camel/component/aws2/ddb/Ddb2Producer.java b/components/camel-aws/camel-aws2-ddb/src/main/java/org/apache/camel/component/aws2/ddb/Ddb2Producer.java
index ccb465dd492..a895302db37 100644
--- a/components/camel-aws/camel-aws2-ddb/src/main/java/org/apache/camel/component/aws2/ddb/Ddb2Producer.java
+++ b/components/camel-aws/camel-aws2-ddb/src/main/java/org/apache/camel/component/aws2/ddb/Ddb2Producer.java
@@ -18,6 +18,9 @@ package org.apache.camel.component.aws2.ddb;
 
 import org.apache.camel.Endpoint;
 import org.apache.camel.Exchange;
+import org.apache.camel.health.HealthCheck;
+import org.apache.camel.health.HealthCheckHelper;
+import org.apache.camel.health.WritableHealthCheckRepository;
 import org.apache.camel.support.DefaultProducer;
 import org.apache.camel.util.URISupport;
 
@@ -28,6 +31,8 @@ import org.apache.camel.util.URISupport;
 public class Ddb2Producer extends DefaultProducer {
 
     private transient String ddbProducerToString;
+    private HealthCheck producerHealthCheck;
+    private WritableHealthCheckRepository healthCheckRepository;
 
     public Ddb2Producer(Endpoint endpoint) {
         super(endpoint);
@@ -92,4 +97,30 @@ public class Ddb2Producer extends DefaultProducer {
     public Ddb2Endpoint getEndpoint() {
         return (Ddb2Endpoint) super.getEndpoint();
     }
+
+    @Override
+    protected void doStart() throws Exception {
+        // health-check is optional so discover and resolve
+        healthCheckRepository = HealthCheckHelper.getHealthCheckRepository(
+                getEndpoint().getCamelContext(),
+                "components",
+                WritableHealthCheckRepository.class);
+
+        if (healthCheckRepository != null) {
+            String id = getEndpoint().getId();
+            producerHealthCheck = new Db2ProducerHealthCheck(getEndpoint(), id);
+            producerHealthCheck.setEnabled(getEndpoint().getComponent().isHealthCheckEnabled()
+                    && getEndpoint().getComponent().isHealthCheckProducerEnabled());
+            healthCheckRepository.addHealthCheck(producerHealthCheck);
+        }
+    }
+
+    @Override
+    protected void doStop() throws Exception {
+        if (healthCheckRepository != null && producerHealthCheck != null) {
+            healthCheckRepository.removeHealthCheck(producerHealthCheck);
+            producerHealthCheck = null;
+        }
+    }
+
 }
diff --git a/components/camel-aws/camel-aws2-ddb/src/test/java/org/apache/camel/component/aws2/ddb/Ddb2ClientHealthCheckProfileCredsTest.java b/components/camel-aws/camel-aws2-ddb/src/test/java/org/apache/camel/component/aws2/ddb/Ddb2ProducerHealthCheckProfileCredsTest.java
similarity index 86%
rename from components/camel-aws/camel-aws2-ddb/src/test/java/org/apache/camel/component/aws2/ddb/Ddb2ClientHealthCheckProfileCredsTest.java
rename to components/camel-aws/camel-aws2-ddb/src/test/java/org/apache/camel/component/aws2/ddb/Ddb2ProducerHealthCheckProfileCredsTest.java
index 124f97ccce8..2ea3840dc38 100644
--- a/components/camel-aws/camel-aws2-ddb/src/test/java/org/apache/camel/component/aws2/ddb/Ddb2ClientHealthCheckProfileCredsTest.java
+++ b/components/camel-aws/camel-aws2-ddb/src/test/java/org/apache/camel/component/aws2/ddb/Ddb2ProducerHealthCheckProfileCredsTest.java
@@ -28,16 +28,11 @@ import org.apache.camel.health.HealthCheckRegistry;
 import org.apache.camel.impl.health.DefaultHealthCheckRegistry;
 import org.apache.camel.test.junit5.CamelTestSupport;
 import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Disabled;
 import org.junit.jupiter.api.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 import static org.testcontainers.shaded.org.awaitility.Awaitility.await;
 
-public class Ddb2ClientHealthCheckProfileCredsTest extends CamelTestSupport {
-
-    private static final Logger LOG = LoggerFactory.getLogger(Ddb2ClientHealthCheckProfileCredsTest.class);
+public class Ddb2ProducerHealthCheckProfileCredsTest extends CamelTestSupport {
 
     CamelContext context;
 
@@ -73,7 +68,6 @@ public class Ddb2ClientHealthCheckProfileCredsTest extends CamelTestSupport {
     }
 
     @Test
-    @Disabled("Do not register the Producer Health Check until we solve CAMEL-18992")
     public void testConnectivity() {
 
         Collection<HealthCheck.Result> res = HealthCheckHelper.invokeLiveness(context);
@@ -85,9 +79,7 @@ public class Ddb2ClientHealthCheckProfileCredsTest extends CamelTestSupport {
             Collection<HealthCheck.Result> res2 = HealthCheckHelper.invokeReadiness(context);
             boolean down = res2.stream().allMatch(r -> r.getState().equals(HealthCheck.State.DOWN));
             boolean containsAws2DdbHealthCheck = res2.stream()
-                    .filter(result -> result.getCheck().getId().startsWith("consumer:ddb-route"))
-                    .findAny()
-                    .isPresent();
+                    .anyMatch(result -> result.getCheck().getId().startsWith("aws2-ddb-producer"));
 
             Assertions.assertTrue(down, "liveness check");
             Assertions.assertTrue(containsAws2DdbHealthCheck, "aws2-ddb check");
diff --git a/components/camel-aws/camel-aws2-ddb/src/test/java/org/apache/camel/component/aws2/ddb/Ddb2ClientHealthCheckStaticCredsTest.java b/components/camel-aws/camel-aws2-ddb/src/test/java/org/apache/camel/component/aws2/ddb/Ddb2ProducerHealthCheckStaticCredsTest.java
similarity index 86%
rename from components/camel-aws/camel-aws2-ddb/src/test/java/org/apache/camel/component/aws2/ddb/Ddb2ClientHealthCheckStaticCredsTest.java
rename to components/camel-aws/camel-aws2-ddb/src/test/java/org/apache/camel/component/aws2/ddb/Ddb2ProducerHealthCheckStaticCredsTest.java
index 2751854e6b5..a60ea8356d6 100644
--- a/components/camel-aws/camel-aws2-ddb/src/test/java/org/apache/camel/component/aws2/ddb/Ddb2ClientHealthCheckStaticCredsTest.java
+++ b/components/camel-aws/camel-aws2-ddb/src/test/java/org/apache/camel/component/aws2/ddb/Ddb2ProducerHealthCheckStaticCredsTest.java
@@ -28,16 +28,11 @@ import org.apache.camel.health.HealthCheckRegistry;
 import org.apache.camel.impl.health.DefaultHealthCheckRegistry;
 import org.apache.camel.test.junit5.CamelTestSupport;
 import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Disabled;
 import org.junit.jupiter.api.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 import static org.testcontainers.shaded.org.awaitility.Awaitility.await;
 
-public class Ddb2ClientHealthCheckStaticCredsTest extends CamelTestSupport {
-
-    private static final Logger LOG = LoggerFactory.getLogger(Ddb2ClientHealthCheckStaticCredsTest.class);
+public class Ddb2ProducerHealthCheckStaticCredsTest extends CamelTestSupport {
 
     CamelContext context;
 
@@ -73,7 +68,6 @@ public class Ddb2ClientHealthCheckStaticCredsTest extends CamelTestSupport {
     }
 
     @Test
-    @Disabled("Do not register the Producer Health Check until we solve CAMEL-18992")
     public void testConnectivity() {
 
         Collection<HealthCheck.Result> res = HealthCheckHelper.invokeLiveness(context);
@@ -85,9 +79,7 @@ public class Ddb2ClientHealthCheckStaticCredsTest extends CamelTestSupport {
             Collection<HealthCheck.Result> res2 = HealthCheckHelper.invokeReadiness(context);
             boolean down = res2.stream().allMatch(r -> r.getState().equals(HealthCheck.State.DOWN));
             boolean containsAws2DdbHealthCheck = res2.stream()
-                    .filter(result -> result.getCheck().getId().startsWith("consumer:ddb-route"))
-                    .findAny()
-                    .isPresent();
+                    .anyMatch(result -> result.getCheck().getId().startsWith("aws2-ddb-producer"));
 
             Assertions.assertTrue(down, "liveness check");
             Assertions.assertTrue(containsAws2DdbHealthCheck, "aws2-ddb check");