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:28 UTC

[camel] branch hc-producer created (now 748bace8873)

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

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


      at 748bace8873 CAMEL-19645: camel-aws - producer health check

This branch includes the following new commits:

     new 8284ce4aae9 CAMEL-19645: camel-aws - producer health check
     new b2d65185098 CAMEL-19645: camel-aws - producer health check
     new d0db4f0e9a3 CAMEL-19645: camel-aws - producer health check
     new ea264fd327a CAMEL-19645: camel-aws - producer health check
     new fd0bd08f0d0 CAMEL-19645: camel-aws - producer health check
     new c97b047cd18 CAMEL-19645: camel-aws - producer health check
     new 3f1025ca572 CAMEL-19645: camel-aws - producer health check
     new e2f35cc3d26 CAMEL-19645: camel-aws - producer health check
     new ae2d5c82324 CAMEL-19645: camel-aws - producer health check
     new 76cee9c4960 CAMEL-19645: camel-aws - producer health check
     new 5628a80f361 CAMEL-19645: camel-aws - producer health check
     new 1edc720e34c CAMEL-19645: camel-aws - producer health check
     new 748bace8873 CAMEL-19645: camel-aws - producer health check

The 13 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



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

Posted by da...@apache.org.
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");


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

Posted by da...@apache.org.
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 e2f35cc3d26695df1a0902d3f8b6f4219747d4e8
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri Jul 28 10:06:16 2023 +0200

    CAMEL-19645: camel-aws - producer health check
---
 .../component/aws2/mq/MQ2ComponentConfigurer.java  | 18 +++++++++++++
 .../apache/camel/component/aws2/mq/aws2-mq.json    |  7 +++--
 .../camel/component/aws2/mq/MQ2Component.java      |  5 ++--
 .../camel/component/aws2/mq/MQ2Endpoint.java       | 24 ++++-------------
 .../camel/component/aws2/mq/MQ2Producer.java       | 31 ++++++++++++++++++++++
 ...ealthCheck.java => MQ2ProducerHealthCheck.java} |  6 ++---
 ...=> MQ2ProducerHealthCheckProfileCredsTest.java} | 13 ++-------
 ... => MQ2ProducerHealthCheckStaticCredsTest.java} | 13 ++-------
 8 files changed, 69 insertions(+), 48 deletions(-)

diff --git a/components/camel-aws/camel-aws2-mq/src/generated/java/org/apache/camel/component/aws2/mq/MQ2ComponentConfigurer.java b/components/camel-aws/camel-aws2-mq/src/generated/java/org/apache/camel/component/aws2/mq/MQ2ComponentConfigurer.java
index 81f9f1f4d33..d1ef7bfa9f6 100644
--- a/components/camel-aws/camel-aws2-mq/src/generated/java/org/apache/camel/component/aws2/mq/MQ2ComponentConfigurer.java
+++ b/components/camel-aws/camel-aws2-mq/src/generated/java/org/apache/camel/component/aws2/mq/MQ2ComponentConfigurer.java
@@ -35,6 +35,12 @@ public class MQ2ComponentConfigurer 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.mq.MQ2Configuration.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 "operation": getOrCreateConfiguration(target).setOperation(property(camelContext, org.apache.camel.component.aws2.mq.MQ2Operations.class, value)); return true;
@@ -80,6 +86,12 @@ public class MQ2ComponentConfigurer extends PropertyConfigurerSupport implements
         case "autowiredenabled":
         case "autowiredEnabled": return boolean.class;
         case "configuration": return org.apache.camel.component.aws2.mq.MQ2Configuration.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 "operation": return org.apache.camel.component.aws2.mq.MQ2Operations.class;
@@ -121,6 +133,12 @@ public class MQ2ComponentConfigurer 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 "operation": return getOrCreateConfiguration(target).getOperation();
diff --git a/components/camel-aws/camel-aws2-mq/src/generated/resources/org/apache/camel/component/aws2/mq/aws2-mq.json b/components/camel-aws/camel-aws2-mq/src/generated/resources/org/apache/camel/component/aws2/mq/aws2-mq.json
index 9c0aebec79e..ace81ddec57 100644
--- a/components/camel-aws/camel-aws2-mq/src/generated/resources/org/apache/camel/component/aws2/mq/aws2-mq.json
+++ b/components/camel-aws/camel-aws2-mq/src/generated/resources/org/apache/camel/component/aws2/mq/aws2-mq.json
@@ -38,8 +38,11 @@
     "useDefaultCredentialsProvider": { "index": 13, "kind": "property", "displayName": "Use Default 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.mq.MQ2Configuration", "configurationField": "configuration", "description": "Set whether the MQ client should expect to load credentials t [...]
     "useProfileCredentialsProvider": { "index": 14, "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.mq.MQ2Configuration", "configurationField": "configuration", "description": "Set whether the MQ client should expect to load credentials t [...]
     "autowiredEnabled": { "index": 15, "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": 16, "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.mq.MQ2Configuration", "configurationField": "configuration", "description": "Amazon AWS Access Key" },
-    "secretKey": { "index": 17, "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.mq.MQ2Configuration", "configurationField": "configuration", "description": "Amazon AWS Secret Key" }
+    "healthCheckConsumerEnabled": { "index": 16, "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": 17, "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": 18, "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": 19, "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.mq.MQ2Configuration", "configurationField": "configuration", "description": "Amazon AWS Access Key" },
+    "secretKey": { "index": 20, "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.mq.MQ2Configuration", "configurationField": "configuration", "description": "Amazon AWS Secret Key" }
   },
   "headers": {
     "CamelAwsMQOperation": { "index": 0, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The operation we want to perform", "constantName": "org.apache.camel.component.aws2.mq.MQ2Constants#OPERATION" },
diff --git a/components/camel-aws/camel-aws2-mq/src/main/java/org/apache/camel/component/aws2/mq/MQ2Component.java b/components/camel-aws/camel-aws2-mq/src/main/java/org/apache/camel/component/aws2/mq/MQ2Component.java
index 1bd884dfeeb..9905be941f5 100644
--- a/components/camel-aws/camel-aws2-mq/src/main/java/org/apache/camel/component/aws2/mq/MQ2Component.java
+++ b/components/camel-aws/camel-aws2-mq/src/main/java/org/apache/camel/component/aws2/mq/MQ2Component.java
@@ -22,13 +22,14 @@ 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 MQ SDK v2.
  */
 @Component("aws2-mq")
-public class MQ2Component extends DefaultComponent {
+public class MQ2Component extends HealthCheckComponent {
+
     @Metadata
     private MQ2Configuration configuration = new MQ2Configuration();
 
diff --git a/components/camel-aws/camel-aws2-mq/src/main/java/org/apache/camel/component/aws2/mq/MQ2Endpoint.java b/components/camel-aws/camel-aws2-mq/src/main/java/org/apache/camel/component/aws2/mq/MQ2Endpoint.java
index 770e8f33a0c..77ae086ab41 100644
--- a/components/camel-aws/camel-aws2-mq/src/main/java/org/apache/camel/component/aws2/mq/MQ2Endpoint.java
+++ b/components/camel-aws/camel-aws2-mq/src/main/java/org/apache/camel/component/aws2/mq/MQ2Endpoint.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.mq.client.MQ2ClientFactory;
-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.ScheduledPollEndpoint;
@@ -39,9 +37,6 @@ public class MQ2Endpoint extends ScheduledPollEndpoint {
 
     private MqClient mqClient;
 
-    private ComponentsHealthCheckRepository healthCheckRepository;
-    private MQ2ClientHealthCheck clientHealthCheck;
-
     @UriParam
     private MQ2Configuration configuration;
 
@@ -50,6 +45,11 @@ public class MQ2Endpoint extends ScheduledPollEndpoint {
         this.configuration = configuration;
     }
 
+    @Override
+    public MQ2Component getComponent() {
+        return (MQ2Component) super.getComponent();
+    }
+
     @Override
     public Consumer createConsumer(Processor processor) throws Exception {
         throw new UnsupportedOperationException("You cannot receive messages from this endpoint");
@@ -67,24 +67,10 @@ public class MQ2Endpoint extends ScheduledPollEndpoint {
         mqClient = configuration.getAmazonMqClient() != null
                 ? configuration.getAmazonMqClient()
                 : MQ2ClientFactory.getMqClient(configuration).getMqClient();
-
-        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 MQ2ClientHealthCheck(this, getId());
-            // healthCheckRepository.addHealthCheck(clientHealthCheck);
-        }
     }
 
     @Override
     public void doStop() throws Exception {
-        if (healthCheckRepository != null && clientHealthCheck != null) {
-            healthCheckRepository.removeHealthCheck(clientHealthCheck);
-            clientHealthCheck = null;
-        }
-
         if (ObjectHelper.isEmpty(configuration.getAmazonMqClient())) {
             if (mqClient != null) {
                 mqClient.close();
diff --git a/components/camel-aws/camel-aws2-mq/src/main/java/org/apache/camel/component/aws2/mq/MQ2Producer.java b/components/camel-aws/camel-aws2-mq/src/main/java/org/apache/camel/component/aws2/mq/MQ2Producer.java
index 7fa537f4ee2..d67ce37e0b5 100644
--- a/components/camel-aws/camel-aws2-mq/src/main/java/org/apache/camel/component/aws2/mq/MQ2Producer.java
+++ b/components/camel-aws/camel-aws2-mq/src/main/java/org/apache/camel/component/aws2/mq/MQ2Producer.java
@@ -22,6 +22,9 @@ import org.apache.camel.Endpoint;
 import org.apache.camel.Exchange;
 import org.apache.camel.InvalidPayloadException;
 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;
 import org.apache.camel.util.ObjectHelper;
 import org.apache.camel.util.URISupport;
@@ -54,6 +57,8 @@ public class MQ2Producer extends DefaultProducer {
     private static final Logger LOG = LoggerFactory.getLogger(MQ2Producer.class);
 
     private transient String mqProducerToString;
+    private HealthCheck producerHealthCheck;
+    private WritableHealthCheckRepository healthCheckRepository;
 
     public MQ2Producer(Endpoint endpoint) {
         super(endpoint);
@@ -370,4 +375,30 @@ public class MQ2Producer extends DefaultProducer {
     public static Message getMessageForResponse(final Exchange exchange) {
         return exchange.getMessage();
     }
+
+    @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 MQ2ProducerHealthCheck(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-mq/src/main/java/org/apache/camel/component/aws2/mq/MQ2ClientHealthCheck.java b/components/camel-aws/camel-aws2-mq/src/main/java/org/apache/camel/component/aws2/mq/MQ2ProducerHealthCheck.java
similarity index 93%
rename from components/camel-aws/camel-aws2-mq/src/main/java/org/apache/camel/component/aws2/mq/MQ2ClientHealthCheck.java
rename to components/camel-aws/camel-aws2-mq/src/main/java/org/apache/camel/component/aws2/mq/MQ2ProducerHealthCheck.java
index ec9e0bd54a2..bb711198777 100644
--- a/components/camel-aws/camel-aws2-mq/src/main/java/org/apache/camel/component/aws2/mq/MQ2ClientHealthCheck.java
+++ b/components/camel-aws/camel-aws2-mq/src/main/java/org/apache/camel/component/aws2/mq/MQ2ProducerHealthCheck.java
@@ -27,12 +27,12 @@ import software.amazon.awssdk.regions.Region;
 import software.amazon.awssdk.services.mq.MqClient;
 import software.amazon.awssdk.services.mq.model.ListBrokersRequest;
 
-public class MQ2ClientHealthCheck extends AbstractHealthCheck {
+public class MQ2ProducerHealthCheck extends AbstractHealthCheck {
 
     private final MQ2Endpoint mq2Endpoint;
 
-    public MQ2ClientHealthCheck(MQ2Endpoint mq2Endpoint, String clientId) {
-        super("camel", "aws2-mq-client-" + clientId);
+    public MQ2ProducerHealthCheck(MQ2Endpoint mq2Endpoint, String clientId) {
+        super("camel", "aws2-mq-producer-" + clientId);
         this.mq2Endpoint = mq2Endpoint;
     }
 
diff --git a/components/camel-aws/camel-aws2-mq/src/test/java/org/apache/camel/component/aws2/mq/MQ2ClientHealthCheckProfileCredsTest.java b/components/camel-aws/camel-aws2-mq/src/test/java/org/apache/camel/component/aws2/mq/MQ2ProducerHealthCheckProfileCredsTest.java
similarity index 87%
rename from components/camel-aws/camel-aws2-mq/src/test/java/org/apache/camel/component/aws2/mq/MQ2ClientHealthCheckProfileCredsTest.java
rename to components/camel-aws/camel-aws2-mq/src/test/java/org/apache/camel/component/aws2/mq/MQ2ProducerHealthCheckProfileCredsTest.java
index 11aa2098050..81fc4a24a31 100644
--- a/components/camel-aws/camel-aws2-mq/src/test/java/org/apache/camel/component/aws2/mq/MQ2ClientHealthCheckProfileCredsTest.java
+++ b/components/camel-aws/camel-aws2-mq/src/test/java/org/apache/camel/component/aws2/mq/MQ2ProducerHealthCheckProfileCredsTest.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 MQ2ClientHealthCheckProfileCredsTest extends CamelTestSupport {
-
-    private static final Logger LOG = LoggerFactory.getLogger(MQ2ClientHealthCheckProfileCredsTest.class);
+public class MQ2ProducerHealthCheckProfileCredsTest extends CamelTestSupport {
 
     CamelContext context;
 
@@ -73,9 +68,7 @@ public class MQ2ClientHealthCheckProfileCredsTest 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);
         boolean up = res.stream().allMatch(r -> r.getState().equals(HealthCheck.State.UP));
         Assertions.assertTrue(up, "liveness check");
@@ -85,9 +78,7 @@ public class MQ2ClientHealthCheckProfileCredsTest extends CamelTestSupport {
             Collection<HealthCheck.Result> res2 = HealthCheckHelper.invokeReadiness(context);
             boolean down = res2.stream().allMatch(r -> r.getState().equals(HealthCheck.State.DOWN));
             boolean containsAwsMqHealthCheck = res2.stream()
-                    .filter(result -> result.getCheck().getId().startsWith("aws2-mq-client"))
-                    .findAny()
-                    .isPresent();
+                    .anyMatch(result -> result.getCheck().getId().startsWith("aws2-mq-producer"));
             boolean hasRegionMessage = res2.stream()
                     .anyMatch(r -> r.getMessage().stream().anyMatch(msg -> msg.contains("region")));
             Assertions.assertTrue(down, "liveness check");
diff --git a/components/camel-aws/camel-aws2-mq/src/test/java/org/apache/camel/component/aws2/mq/MQ2ClientHealthCheckStaticCredsTest.java b/components/camel-aws/camel-aws2-mq/src/test/java/org/apache/camel/component/aws2/mq/MQ2ProducerHealthCheckStaticCredsTest.java
similarity index 87%
rename from components/camel-aws/camel-aws2-mq/src/test/java/org/apache/camel/component/aws2/mq/MQ2ClientHealthCheckStaticCredsTest.java
rename to components/camel-aws/camel-aws2-mq/src/test/java/org/apache/camel/component/aws2/mq/MQ2ProducerHealthCheckStaticCredsTest.java
index 56a596b01ed..b34d66686f1 100644
--- a/components/camel-aws/camel-aws2-mq/src/test/java/org/apache/camel/component/aws2/mq/MQ2ClientHealthCheckStaticCredsTest.java
+++ b/components/camel-aws/camel-aws2-mq/src/test/java/org/apache/camel/component/aws2/mq/MQ2ProducerHealthCheckStaticCredsTest.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 MQ2ClientHealthCheckStaticCredsTest extends CamelTestSupport {
-
-    private static final Logger LOG = LoggerFactory.getLogger(MQ2ClientHealthCheckStaticCredsTest.class);
+public class MQ2ProducerHealthCheckStaticCredsTest extends CamelTestSupport {
 
     CamelContext context;
 
@@ -73,9 +68,7 @@ public class MQ2ClientHealthCheckStaticCredsTest 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);
         boolean up = res.stream().allMatch(r -> r.getState().equals(HealthCheck.State.UP));
         Assertions.assertTrue(up, "liveness check");
@@ -85,9 +78,7 @@ public class MQ2ClientHealthCheckStaticCredsTest extends CamelTestSupport {
             Collection<HealthCheck.Result> res2 = HealthCheckHelper.invokeReadiness(context);
             boolean down = res2.stream().allMatch(r -> r.getState().equals(HealthCheck.State.DOWN));
             boolean containsAwsMQHealthCheck = res2.stream()
-                    .filter(result -> result.getCheck().getId().startsWith("aws2-mq-client"))
-                    .findAny()
-                    .isPresent();
+                    .anyMatch(result -> result.getCheck().getId().startsWith("aws2-mq-producer"));
             boolean hasRegionMessage = res2.stream()
                     .anyMatch(r -> r.getMessage().stream().anyMatch(msg -> msg.contains("region")));
             Assertions.assertTrue(down, "liveness check");


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

Posted by da...@apache.org.
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 fd0bd08f0d0cbe4638c6603104122b113676336e
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri Jul 28 09:58:08 2023 +0200

    CAMEL-19645: camel-aws - producer health check
---
 .../EventbridgeComponentConfigurer.java            | 18 +++++++++++++
 .../aws2/eventbridge/aws2-eventbridge.json         |  7 +++--
 .../aws2/eventbridge/EventbridgeComponent.java     |  5 ++--
 .../aws2/eventbridge/EventbridgeEndpoint.java      | 24 ++++-------------
 .../aws2/eventbridge/EventbridgeProducer.java      | 31 ++++++++++++++++++++++
 ...ck.java => EventbridgeProducerHealthCheck.java} |  6 ++---
 ...bridgeProducerHealthCheckProfileCredsTest.java} | 13 ++-------
 ...tbridgeProducerHealthCheckStaticCredsTest.java} | 12 ++-------
 8 files changed, 69 insertions(+), 47 deletions(-)

diff --git a/components/camel-aws/camel-aws2-eventbridge/src/generated/java/org/apache/camel/component/aws2/eventbridge/EventbridgeComponentConfigurer.java b/components/camel-aws/camel-aws2-eventbridge/src/generated/java/org/apache/camel/component/aws2/eventbridge/EventbridgeComponentConfigurer.java
index b7a8c3f7fad..0e386323ee4 100644
--- a/components/camel-aws/camel-aws2-eventbridge/src/generated/java/org/apache/camel/component/aws2/eventbridge/EventbridgeComponentConfigurer.java
+++ b/components/camel-aws/camel-aws2-eventbridge/src/generated/java/org/apache/camel/component/aws2/eventbridge/EventbridgeComponentConfigurer.java
@@ -37,6 +37,12 @@ public class EventbridgeComponentConfigurer extends PropertyConfigurerSupport im
         case "eventPatternFile": getOrCreateConfiguration(target).setEventPatternFile(property(camelContext, java.lang.String.class, value)); return true;
         case "eventbridgeclient":
         case "eventbridgeClient": getOrCreateConfiguration(target).setEventbridgeClient(property(camelContext, software.amazon.awssdk.services.eventbridge.EventBridgeClient.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 "operation": getOrCreateConfiguration(target).setOperation(property(camelContext, org.apache.camel.component.aws2.eventbridge.EventbridgeOperations.class, value)); return true;
@@ -84,6 +90,12 @@ public class EventbridgeComponentConfigurer extends PropertyConfigurerSupport im
         case "eventPatternFile": return java.lang.String.class;
         case "eventbridgeclient":
         case "eventbridgeClient": return software.amazon.awssdk.services.eventbridge.EventBridgeClient.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 "operation": return org.apache.camel.component.aws2.eventbridge.EventbridgeOperations.class;
@@ -127,6 +139,12 @@ public class EventbridgeComponentConfigurer extends PropertyConfigurerSupport im
         case "eventPatternFile": return getOrCreateConfiguration(target).getEventPatternFile();
         case "eventbridgeclient":
         case "eventbridgeClient": return getOrCreateConfiguration(target).getEventbridgeClient();
+        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 "operation": return getOrCreateConfiguration(target).getOperation();
diff --git a/components/camel-aws/camel-aws2-eventbridge/src/generated/resources/org/apache/camel/component/aws2/eventbridge/aws2-eventbridge.json b/components/camel-aws/camel-aws2-eventbridge/src/generated/resources/org/apache/camel/component/aws2/eventbridge/aws2-eventbridge.json
index 16dc8a82822..d2aecb2457b 100644
--- a/components/camel-aws/camel-aws2-eventbridge/src/generated/resources/org/apache/camel/component/aws2/eventbridge/aws2-eventbridge.json
+++ b/components/camel-aws/camel-aws2-eventbridge/src/generated/resources/org/apache/camel/component/aws2/eventbridge/aws2-eventbridge.json
@@ -39,8 +39,11 @@
     "useDefaultCredentialsProvider": { "index": 14, "kind": "property", "displayName": "Use Default 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.eventbridge.EventbridgeConfiguration", "configurationField": "configuration", "description": "Set whether the Eventbridge client should ex [...]
     "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.eventbridge.EventbridgeConfiguration", "configurationField": "configuration", "description": "Set whether the Eventbridge client should ex [...]
     "autowiredEnabled": { "index": 16, "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": 17, "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.eventbridge.EventbridgeConfiguration", "configurationField": "configuration", "description": "Amazon AWS Access Key" },
-    "secretKey": { "index": 18, "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.eventbridge.EventbridgeConfiguration", "configurationField": "configuration", "description": "Amazon AWS Secret Key" }
+    "healthCheckConsumerEnabled": { "index": 17, "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": 18, "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": 19, "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": 20, "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.eventbridge.EventbridgeConfiguration", "configurationField": "configuration", "description": "Amazon AWS Access Key" },
+    "secretKey": { "index": 21, "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.eventbridge.EventbridgeConfiguration", "configurationField": "configuration", "description": "Amazon AWS Secret Key" }
   },
   "headers": {
     "CamelAwsEventbridgeOperation": { "index": 0, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The operation we want to perform", "constantName": "org.apache.camel.component.aws2.eventbridge.EventbridgeConstants#OPERATION" },
diff --git a/components/camel-aws/camel-aws2-eventbridge/src/main/java/org/apache/camel/component/aws2/eventbridge/EventbridgeComponent.java b/components/camel-aws/camel-aws2-eventbridge/src/main/java/org/apache/camel/component/aws2/eventbridge/EventbridgeComponent.java
index d06d1ffcc59..af08ad47cc2 100644
--- a/components/camel-aws/camel-aws2-eventbridge/src/main/java/org/apache/camel/component/aws2/eventbridge/EventbridgeComponent.java
+++ b/components/camel-aws/camel-aws2-eventbridge/src/main/java/org/apache/camel/component/aws2/eventbridge/EventbridgeComponent.java
@@ -22,13 +22,14 @@ 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 Eventbridge SDK v2.
  */
 @Component("aws2-eventbridge")
-public class EventbridgeComponent extends DefaultComponent {
+public class EventbridgeComponent extends HealthCheckComponent {
+
     @Metadata
     private EventbridgeConfiguration configuration = new EventbridgeConfiguration();
 
diff --git a/components/camel-aws/camel-aws2-eventbridge/src/main/java/org/apache/camel/component/aws2/eventbridge/EventbridgeEndpoint.java b/components/camel-aws/camel-aws2-eventbridge/src/main/java/org/apache/camel/component/aws2/eventbridge/EventbridgeEndpoint.java
index f1557c53149..3793b6238ce 100644
--- a/components/camel-aws/camel-aws2-eventbridge/src/main/java/org/apache/camel/component/aws2/eventbridge/EventbridgeEndpoint.java
+++ b/components/camel-aws/camel-aws2-eventbridge/src/main/java/org/apache/camel/component/aws2/eventbridge/EventbridgeEndpoint.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.eventbridge.client.EventbridgeClientFactory;
-import org.apache.camel.health.HealthCheckHelper;
-import org.apache.camel.impl.health.ComponentsHealthCheckRepository;
 import org.apache.camel.spi.Metadata;
 import org.apache.camel.spi.UriEndpoint;
 import org.apache.camel.spi.UriParam;
@@ -44,9 +42,6 @@ public class EventbridgeEndpoint extends DefaultEndpoint {
 
     private EventBridgeClient eventbridgeClient;
 
-    private ComponentsHealthCheckRepository healthCheckRepository;
-    private EventbridgeClientHealthCheck clientHealthCheck;
-
     @UriPath(description = "Event bus name or ARN")
     @Metadata(required = true)
     private String eventbusNameOrArn; // to support component docs
@@ -58,6 +53,11 @@ public class EventbridgeEndpoint extends DefaultEndpoint {
         this.configuration = configuration;
     }
 
+    @Override
+    public EventbridgeComponent getComponent() {
+        return (EventbridgeComponent) super.getComponent();
+    }
+
     @Override
     public Consumer createConsumer(Processor processor) throws Exception {
         throw new UnsupportedOperationException("You cannot receive messages from this endpoint");
@@ -75,24 +75,10 @@ public class EventbridgeEndpoint extends DefaultEndpoint {
         eventbridgeClient = configuration.getEventbridgeClient() != null
                 ? configuration.getEventbridgeClient()
                 : EventbridgeClientFactory.getEventbridgeClient(configuration).getEventbridgeClient();
-
-        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 EventbridgeClientHealthCheck(this, getId());
-            // healthCheckRepository.addHealthCheck(clientHealthCheck);
-        }
     }
 
     @Override
     public void doStop() throws Exception {
-        if (healthCheckRepository != null && clientHealthCheck != null) {
-            healthCheckRepository.removeHealthCheck(clientHealthCheck);
-            clientHealthCheck = null;
-        }
-
         if (ObjectHelper.isEmpty(configuration.getEventbridgeClient())) {
             if (eventbridgeClient != null) {
                 eventbridgeClient.close();
diff --git a/components/camel-aws/camel-aws2-eventbridge/src/main/java/org/apache/camel/component/aws2/eventbridge/EventbridgeProducer.java b/components/camel-aws/camel-aws2-eventbridge/src/main/java/org/apache/camel/component/aws2/eventbridge/EventbridgeProducer.java
index 519ebf45868..8e4d7828c41 100644
--- a/components/camel-aws/camel-aws2-eventbridge/src/main/java/org/apache/camel/component/aws2/eventbridge/EventbridgeProducer.java
+++ b/components/camel-aws/camel-aws2-eventbridge/src/main/java/org/apache/camel/component/aws2/eventbridge/EventbridgeProducer.java
@@ -26,6 +26,9 @@ import org.apache.camel.Endpoint;
 import org.apache.camel.Exchange;
 import org.apache.camel.InvalidPayloadException;
 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;
 import org.apache.camel.support.ResourceHelper;
 import org.apache.camel.util.ObjectHelper;
@@ -69,6 +72,8 @@ public class EventbridgeProducer extends DefaultProducer {
     private static final Logger LOG = LoggerFactory.getLogger(EventbridgeProducer.class);
 
     private transient String eventbridgeProducerToString;
+    private HealthCheck producerHealthCheck;
+    private WritableHealthCheckRepository healthCheckRepository;
 
     public EventbridgeProducer(Endpoint endpoint) {
         super(endpoint);
@@ -548,4 +553,30 @@ public class EventbridgeProducer extends DefaultProducer {
     public static Message getMessageForResponse(final Exchange exchange) {
         return exchange.getMessage();
     }
+
+    @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 EventbridgeProducerHealthCheck(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-eventbridge/src/main/java/org/apache/camel/component/aws2/eventbridge/EventbridgeClientHealthCheck.java b/components/camel-aws/camel-aws2-eventbridge/src/main/java/org/apache/camel/component/aws2/eventbridge/EventbridgeProducerHealthCheck.java
similarity index 92%
rename from components/camel-aws/camel-aws2-eventbridge/src/main/java/org/apache/camel/component/aws2/eventbridge/EventbridgeClientHealthCheck.java
rename to components/camel-aws/camel-aws2-eventbridge/src/main/java/org/apache/camel/component/aws2/eventbridge/EventbridgeProducerHealthCheck.java
index d60d04d7901..bc4af16a873 100644
--- a/components/camel-aws/camel-aws2-eventbridge/src/main/java/org/apache/camel/component/aws2/eventbridge/EventbridgeClientHealthCheck.java
+++ b/components/camel-aws/camel-aws2-eventbridge/src/main/java/org/apache/camel/component/aws2/eventbridge/EventbridgeProducerHealthCheck.java
@@ -27,12 +27,12 @@ import software.amazon.awssdk.regions.Region;
 import software.amazon.awssdk.services.eventbridge.EventBridgeClient;
 import software.amazon.awssdk.services.eventbridge.model.ListEventBusesRequest;
 
-public class EventbridgeClientHealthCheck extends AbstractHealthCheck {
+public class EventbridgeProducerHealthCheck extends AbstractHealthCheck {
 
     private final EventbridgeEndpoint eventbridgeEndpoint;
 
-    public EventbridgeClientHealthCheck(EventbridgeEndpoint eventbridgeEndpoint, String clientId) {
-        super("camel", "aws2-eventbridge-client-" + clientId);
+    public EventbridgeProducerHealthCheck(EventbridgeEndpoint eventbridgeEndpoint, String clientId) {
+        super("camel", "aws2-eventbridge-producer-" + clientId);
         this.eventbridgeEndpoint = eventbridgeEndpoint;
     }
 
diff --git a/components/camel-aws/camel-aws2-eventbridge/src/test/java/org/apache/camel/component/aws2/eventbridge/EventbridgeClientHealthCheckProfileCredsTest.java b/components/camel-aws/camel-aws2-eventbridge/src/test/java/org/apache/camel/component/aws2/eventbridge/EventbridgeProducerHealthCheckProfileCredsTest.java
similarity index 86%
rename from components/camel-aws/camel-aws2-eventbridge/src/test/java/org/apache/camel/component/aws2/eventbridge/EventbridgeClientHealthCheckProfileCredsTest.java
rename to components/camel-aws/camel-aws2-eventbridge/src/test/java/org/apache/camel/component/aws2/eventbridge/EventbridgeProducerHealthCheckProfileCredsTest.java
index 9c74813ec65..6ef04ea30a4 100644
--- a/components/camel-aws/camel-aws2-eventbridge/src/test/java/org/apache/camel/component/aws2/eventbridge/EventbridgeClientHealthCheckProfileCredsTest.java
+++ b/components/camel-aws/camel-aws2-eventbridge/src/test/java/org/apache/camel/component/aws2/eventbridge/EventbridgeProducerHealthCheckProfileCredsTest.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 EventbridgeClientHealthCheckProfileCredsTest extends CamelTestSupport {
-
-    private static final Logger LOG = LoggerFactory.getLogger(EventbridgeClientHealthCheckProfileCredsTest.class);
+public class EventbridgeProducerHealthCheckProfileCredsTest extends CamelTestSupport {
 
     CamelContext context;
 
@@ -73,9 +68,7 @@ public class EventbridgeClientHealthCheckProfileCredsTest extends CamelTestSuppo
     }
 
     @Test
-    @Disabled("Do not register the Producer Health Check until we solve CAMEL-18992")
     public void testConnectivity() {
-
         Collection<HealthCheck.Result> res = HealthCheckHelper.invokeLiveness(context);
         boolean up = res.stream().allMatch(r -> r.getState().equals(HealthCheck.State.UP));
         Assertions.assertTrue(up, "liveness check");
@@ -85,9 +78,7 @@ public class EventbridgeClientHealthCheckProfileCredsTest extends CamelTestSuppo
             Collection<HealthCheck.Result> res2 = HealthCheckHelper.invokeReadiness(context);
             boolean down = res2.stream().allMatch(r -> r.getState().equals(HealthCheck.State.DOWN));
             boolean containsAwsEventbridgeHealthCheck = res2.stream()
-                    .filter(result -> result.getCheck().getId().startsWith("aws2-eventbridge-client"))
-                    .findAny()
-                    .isPresent();
+                    .anyMatch(result -> result.getCheck().getId().startsWith("aws2-eventbridge-producer"));
             boolean hasRegionMessage = res2.stream()
                     .anyMatch(r -> r.getMessage().stream().anyMatch(msg -> msg.contains("region")));
             Assertions.assertTrue(down, "liveness check");
diff --git a/components/camel-aws/camel-aws2-eventbridge/src/test/java/org/apache/camel/component/aws2/eventbridge/EventbridgeClientHealthCheckStaticCredsTest.java b/components/camel-aws/camel-aws2-eventbridge/src/test/java/org/apache/camel/component/aws2/eventbridge/EventbridgeProducerHealthCheckStaticCredsTest.java
similarity index 86%
rename from components/camel-aws/camel-aws2-eventbridge/src/test/java/org/apache/camel/component/aws2/eventbridge/EventbridgeClientHealthCheckStaticCredsTest.java
rename to components/camel-aws/camel-aws2-eventbridge/src/test/java/org/apache/camel/component/aws2/eventbridge/EventbridgeProducerHealthCheckStaticCredsTest.java
index 8c3f43ac686..7e719e02f90 100644
--- a/components/camel-aws/camel-aws2-eventbridge/src/test/java/org/apache/camel/component/aws2/eventbridge/EventbridgeClientHealthCheckStaticCredsTest.java
+++ b/components/camel-aws/camel-aws2-eventbridge/src/test/java/org/apache/camel/component/aws2/eventbridge/EventbridgeProducerHealthCheckStaticCredsTest.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 EventbridgeClientHealthCheckStaticCredsTest extends CamelTestSupport {
-
-    private static final Logger LOG = LoggerFactory.getLogger(EventbridgeClientHealthCheckStaticCredsTest.class);
+public class EventbridgeProducerHealthCheckStaticCredsTest extends CamelTestSupport {
 
     CamelContext context;
 
@@ -73,7 +68,6 @@ public class EventbridgeClientHealthCheckStaticCredsTest extends CamelTestSuppor
     }
 
     @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 EventbridgeClientHealthCheckStaticCredsTest extends CamelTestSuppor
             Collection<HealthCheck.Result> res2 = HealthCheckHelper.invokeReadiness(context);
             boolean down = res2.stream().allMatch(r -> r.getState().equals(HealthCheck.State.DOWN));
             boolean containsAwsEventbridgeHealthCheck = res2.stream()
-                    .filter(result -> result.getCheck().getId().startsWith("aws2-eventbridge-client"))
-                    .findAny()
-                    .isPresent();
+                    .anyMatch(result -> result.getCheck().getId().startsWith("aws2-eventbridge-producer"));
             boolean hasRegionMessage = res2.stream()
                     .anyMatch(r -> r.getMessage().stream().anyMatch(msg -> msg.contains("region")));
             Assertions.assertTrue(down, "liveness check");


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

Posted by da...@apache.org.
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 1edc720e34c013a4228315579215142789240bca
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri Jul 28 10:18:21 2023 +0200

    CAMEL-19645: camel-aws - producer health check
---
 ...AWS2EC2ProducerHealthCheckProfileCredsTest.java |  3 ---
 .../AWS2EC2ProducerHealthCheckStaticCredsTest.java |  3 ---
 .../aws2/msk/MSK2ComponentConfigurer.java          | 18 +++++++++++++
 .../apache/camel/component/aws2/msk/aws2-msk.json  |  7 +++--
 .../camel/component/aws2/msk/MSK2Component.java    |  5 ++--
 .../camel/component/aws2/msk/MSK2Endpoint.java     | 23 ++++------------
 .../camel/component/aws2/msk/MSK2Producer.java     | 31 ++++++++++++++++++++++
 ...althCheck.java => MSK2ProducerHealthCheck.java} |  8 +++---
 ...> MSK2ProducerHealthCheckProfileCredsTest.java} | 13 ++-------
 ...=> MSK2ProducerHealthCheckStaticCredsTest.java} | 13 ++-------
 10 files changed, 69 insertions(+), 55 deletions(-)

diff --git a/components/camel-aws/camel-aws2-ec2/src/test/java/org/apache/camel/component/aws2/ec2/AWS2EC2ProducerHealthCheckProfileCredsTest.java b/components/camel-aws/camel-aws2-ec2/src/test/java/org/apache/camel/component/aws2/ec2/AWS2EC2ProducerHealthCheckProfileCredsTest.java
index 49ffb4ce094..c6025211a45 100644
--- a/components/camel-aws/camel-aws2-ec2/src/test/java/org/apache/camel/component/aws2/ec2/AWS2EC2ProducerHealthCheckProfileCredsTest.java
+++ b/components/camel-aws/camel-aws2-ec2/src/test/java/org/apache/camel/component/aws2/ec2/AWS2EC2ProducerHealthCheckProfileCredsTest.java
@@ -27,7 +27,6 @@ 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 static org.testcontainers.shaded.org.awaitility.Awaitility.await;
@@ -68,9 +67,7 @@ public class AWS2EC2ProducerHealthCheckProfileCredsTest 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);
         boolean up = res.stream().allMatch(r -> r.getState().equals(HealthCheck.State.UP));
         Assertions.assertTrue(up, "liveness check");
diff --git a/components/camel-aws/camel-aws2-ec2/src/test/java/org/apache/camel/component/aws2/ec2/AWS2EC2ProducerHealthCheckStaticCredsTest.java b/components/camel-aws/camel-aws2-ec2/src/test/java/org/apache/camel/component/aws2/ec2/AWS2EC2ProducerHealthCheckStaticCredsTest.java
index 304247663de..3e99f442649 100644
--- a/components/camel-aws/camel-aws2-ec2/src/test/java/org/apache/camel/component/aws2/ec2/AWS2EC2ProducerHealthCheckStaticCredsTest.java
+++ b/components/camel-aws/camel-aws2-ec2/src/test/java/org/apache/camel/component/aws2/ec2/AWS2EC2ProducerHealthCheckStaticCredsTest.java
@@ -27,7 +27,6 @@ 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 static org.testcontainers.shaded.org.awaitility.Awaitility.await;
@@ -68,9 +67,7 @@ public class AWS2EC2ProducerHealthCheckStaticCredsTest 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);
         boolean up = res.stream().allMatch(r -> r.getState().equals(HealthCheck.State.UP));
         Assertions.assertTrue(up, "liveness check");
diff --git a/components/camel-aws/camel-aws2-msk/src/generated/java/org/apache/camel/component/aws2/msk/MSK2ComponentConfigurer.java b/components/camel-aws/camel-aws2-msk/src/generated/java/org/apache/camel/component/aws2/msk/MSK2ComponentConfigurer.java
index 34fff09c8a9..99f7f147360 100644
--- a/components/camel-aws/camel-aws2-msk/src/generated/java/org/apache/camel/component/aws2/msk/MSK2ComponentConfigurer.java
+++ b/components/camel-aws/camel-aws2-msk/src/generated/java/org/apache/camel/component/aws2/msk/MSK2ComponentConfigurer.java
@@ -33,6 +33,12 @@ public class MSK2ComponentConfigurer extends PropertyConfigurerSupport implement
         case "autowiredenabled":
         case "autowiredEnabled": target.setAutowiredEnabled(property(camelContext, boolean.class, value)); return true;
         case "configuration": target.setConfiguration(property(camelContext, org.apache.camel.component.aws2.msk.MSK2Configuration.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 "mskclient":
@@ -78,6 +84,12 @@ public class MSK2ComponentConfigurer extends PropertyConfigurerSupport implement
         case "autowiredenabled":
         case "autowiredEnabled": return boolean.class;
         case "configuration": return org.apache.camel.component.aws2.msk.MSK2Configuration.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 "mskclient":
@@ -119,6 +131,12 @@ public class MSK2ComponentConfigurer extends PropertyConfigurerSupport implement
         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 "mskclient":
diff --git a/components/camel-aws/camel-aws2-msk/src/generated/resources/org/apache/camel/component/aws2/msk/aws2-msk.json b/components/camel-aws/camel-aws2-msk/src/generated/resources/org/apache/camel/component/aws2/msk/aws2-msk.json
index f0a4f3afbaf..9f6e843598c 100644
--- a/components/camel-aws/camel-aws2-msk/src/generated/resources/org/apache/camel/component/aws2/msk/aws2-msk.json
+++ b/components/camel-aws/camel-aws2-msk/src/generated/resources/org/apache/camel/component/aws2/msk/aws2-msk.json
@@ -38,8 +38,11 @@
     "useDefaultCredentialsProvider": { "index": 13, "kind": "property", "displayName": "Use Default 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.msk.MSK2Configuration", "configurationField": "configuration", "description": "Set whether the Kafka client should expect to load credenti [...]
     "useProfileCredentialsProvider": { "index": 14, "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.msk.MSK2Configuration", "configurationField": "configuration", "description": "Set whether the MSK client should expect to load credential [...]
     "autowiredEnabled": { "index": 15, "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": 16, "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.msk.MSK2Configuration", "configurationField": "configuration", "description": "Amazon AWS Access Key" },
-    "secretKey": { "index": 17, "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.msk.MSK2Configuration", "configurationField": "configuration", "description": "Amazon AWS Secret Key" }
+    "healthCheckConsumerEnabled": { "index": 16, "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": 17, "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": 18, "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": 19, "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.msk.MSK2Configuration", "configurationField": "configuration", "description": "Amazon AWS Access Key" },
+    "secretKey": { "index": 20, "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.msk.MSK2Configuration", "configurationField": "configuration", "description": "Amazon AWS Secret Key" }
   },
   "headers": {
     "CamelAwsMSKOperation": { "index": 0, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The operation we want to perform", "constantName": "org.apache.camel.component.aws2.msk.MSK2Constants#OPERATION" },
diff --git a/components/camel-aws/camel-aws2-msk/src/main/java/org/apache/camel/component/aws2/msk/MSK2Component.java b/components/camel-aws/camel-aws2-msk/src/main/java/org/apache/camel/component/aws2/msk/MSK2Component.java
index ffbfd05a268..a0d0b8e29a2 100644
--- a/components/camel-aws/camel-aws2-msk/src/main/java/org/apache/camel/component/aws2/msk/MSK2Component.java
+++ b/components/camel-aws/camel-aws2-msk/src/main/java/org/apache/camel/component/aws2/msk/MSK2Component.java
@@ -22,13 +22,14 @@ 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 MSK SDK v2.
  */
 @Component("aws2-msk")
-public class MSK2Component extends DefaultComponent {
+public class MSK2Component extends HealthCheckComponent {
+
     @Metadata
     private MSK2Configuration configuration = new MSK2Configuration();
 
diff --git a/components/camel-aws/camel-aws2-msk/src/main/java/org/apache/camel/component/aws2/msk/MSK2Endpoint.java b/components/camel-aws/camel-aws2-msk/src/main/java/org/apache/camel/component/aws2/msk/MSK2Endpoint.java
index a67ffbb76a4..8f49781b593 100644
--- a/components/camel-aws/camel-aws2-msk/src/main/java/org/apache/camel/component/aws2/msk/MSK2Endpoint.java
+++ b/components/camel-aws/camel-aws2-msk/src/main/java/org/apache/camel/component/aws2/msk/MSK2Endpoint.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.msk.client.MSK2ClientFactory;
-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.ScheduledPollEndpoint;
@@ -38,8 +36,6 @@ import software.amazon.awssdk.services.kafka.KafkaClient;
              headersClass = MSK2Constants.class)
 public class MSK2Endpoint extends ScheduledPollEndpoint {
 
-    private ComponentsHealthCheckRepository healthCheckRepository;
-    private MSK2HealthCheck clientHealthCheck;
     private KafkaClient mskClient;
 
     @UriParam
@@ -60,6 +56,11 @@ public class MSK2Endpoint extends ScheduledPollEndpoint {
         return new MSK2Producer(this);
     }
 
+    @Override
+    public MSK2Component getComponent() {
+        return (MSK2Component) super.getComponent();
+    }
+
     @Override
     public void doStart() throws Exception {
         super.doStart();
@@ -67,15 +68,6 @@ public class MSK2Endpoint extends ScheduledPollEndpoint {
         mskClient = configuration.getMskClient() != null
                 ? configuration.getMskClient()
                 : MSK2ClientFactory.getKafkaClient(configuration).getKafkaClient();
-        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 MSK2HealthCheck(this, getId());
-            // healthCheckRepository.addHealthCheck(clientHealthCheck);
-        }
-
     }
 
     @Override
@@ -85,11 +77,6 @@ public class MSK2Endpoint extends ScheduledPollEndpoint {
                 mskClient.close();
             }
         }
-        if (healthCheckRepository != null && clientHealthCheck != null) {
-            healthCheckRepository.removeHealthCheck(clientHealthCheck);
-            clientHealthCheck = null;
-        }
-
         super.doStop();
     }
 
diff --git a/components/camel-aws/camel-aws2-msk/src/main/java/org/apache/camel/component/aws2/msk/MSK2Producer.java b/components/camel-aws/camel-aws2-msk/src/main/java/org/apache/camel/component/aws2/msk/MSK2Producer.java
index 02ef13571f8..226118288f1 100644
--- a/components/camel-aws/camel-aws2-msk/src/main/java/org/apache/camel/component/aws2/msk/MSK2Producer.java
+++ b/components/camel-aws/camel-aws2-msk/src/main/java/org/apache/camel/component/aws2/msk/MSK2Producer.java
@@ -20,6 +20,9 @@ import org.apache.camel.Endpoint;
 import org.apache.camel.Exchange;
 import org.apache.camel.InvalidPayloadException;
 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;
 import org.apache.camel.util.ObjectHelper;
 import org.apache.camel.util.URISupport;
@@ -45,6 +48,8 @@ public class MSK2Producer extends DefaultProducer {
     private static final Logger LOG = LoggerFactory.getLogger(MSK2Producer.class);
 
     private transient String mskProducerToString;
+    private HealthCheck producerHealthCheck;
+    private WritableHealthCheckRepository healthCheckRepository;
 
     public MSK2Producer(Endpoint endpoint) {
         super(endpoint);
@@ -251,4 +256,30 @@ public class MSK2Producer extends DefaultProducer {
     public static Message getMessageForResponse(final Exchange exchange) {
         return exchange.getMessage();
     }
+
+    @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 MSK2ProducerHealthCheck(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-msk/src/main/java/org/apache/camel/component/aws2/msk/MSK2HealthCheck.java b/components/camel-aws/camel-aws2-msk/src/main/java/org/apache/camel/component/aws2/msk/MSK2ProducerHealthCheck.java
similarity index 91%
rename from components/camel-aws/camel-aws2-msk/src/main/java/org/apache/camel/component/aws2/msk/MSK2HealthCheck.java
rename to components/camel-aws/camel-aws2-msk/src/main/java/org/apache/camel/component/aws2/msk/MSK2ProducerHealthCheck.java
index 247db802063..168e6ec5c6c 100644
--- a/components/camel-aws/camel-aws2-msk/src/main/java/org/apache/camel/component/aws2/msk/MSK2HealthCheck.java
+++ b/components/camel-aws/camel-aws2-msk/src/main/java/org/apache/camel/component/aws2/msk/MSK2ProducerHealthCheck.java
@@ -25,18 +25,17 @@ import software.amazon.awssdk.regions.Region;
 import software.amazon.awssdk.services.kafka.KafkaClient;
 import software.amazon.awssdk.services.kafka.model.ListClustersRequest;
 
-public class MSK2HealthCheck extends AbstractHealthCheck {
+public class MSK2ProducerHealthCheck extends AbstractHealthCheck {
 
     private final MSK2Endpoint msk2Endpoint;
 
-    public MSK2HealthCheck(MSK2Endpoint msk2Endpoint, String clientId) {
-        super("camel", "aws2-msk-client-" + clientId);
+    public MSK2ProducerHealthCheck(MSK2Endpoint msk2Endpoint, String clientId) {
+        super("camel", "aws2-msk-producer-" + clientId);
         this.msk2Endpoint = msk2Endpoint;
     }
 
     @Override
     protected void doCall(HealthCheckResultBuilder builder, Map<String, Object> options) {
-
         MSK2Configuration configuration = msk2Endpoint.getConfiguration();
         try {
             if (!KafkaClient.serviceMetadata().regions().contains(Region.of(configuration.getRegion()))) {
@@ -56,7 +55,6 @@ public class MSK2HealthCheck extends AbstractHealthCheck {
             return;
         }
         builder.up();
-
     }
 
 }
diff --git a/components/camel-aws/camel-aws2-msk/src/test/java/org/apache/camel/component/aws2/msk/MSK2HealthCheckStaticCredsTest.java b/components/camel-aws/camel-aws2-msk/src/test/java/org/apache/camel/component/aws2/msk/MSK2ProducerHealthCheckProfileCredsTest.java
similarity index 87%
rename from components/camel-aws/camel-aws2-msk/src/test/java/org/apache/camel/component/aws2/msk/MSK2HealthCheckStaticCredsTest.java
rename to components/camel-aws/camel-aws2-msk/src/test/java/org/apache/camel/component/aws2/msk/MSK2ProducerHealthCheckProfileCredsTest.java
index d02ca9d7596..4c916f59206 100644
--- a/components/camel-aws/camel-aws2-msk/src/test/java/org/apache/camel/component/aws2/msk/MSK2HealthCheckStaticCredsTest.java
+++ b/components/camel-aws/camel-aws2-msk/src/test/java/org/apache/camel/component/aws2/msk/MSK2ProducerHealthCheckProfileCredsTest.java
@@ -27,16 +27,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 MSK2HealthCheckStaticCredsTest extends CamelTestSupport {
-
-    private static final Logger LOG = LoggerFactory.getLogger(MSK2HealthCheckStaticCredsTest.class);
+public class MSK2ProducerHealthCheckProfileCredsTest extends CamelTestSupport {
 
     CamelContext context;
 
@@ -72,9 +67,7 @@ public class MSK2HealthCheckStaticCredsTest 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);
         boolean up = res.stream().allMatch(r -> r.getState().equals(HealthCheck.State.UP));
         Assertions.assertTrue(up, "liveness check");
@@ -84,9 +77,7 @@ public class MSK2HealthCheckStaticCredsTest extends CamelTestSupport {
             Collection<HealthCheck.Result> res2 = HealthCheckHelper.invokeReadiness(context);
             boolean down = res2.stream().allMatch(r -> r.getState().equals(HealthCheck.State.DOWN));
             boolean containsAws2AthenaHealthCheck = res2.stream()
-                    .filter(result -> result.getCheck().getId().startsWith("aws2-msk-client"))
-                    .findAny()
-                    .isPresent();
+                    .anyMatch(result -> result.getCheck().getId().startsWith("aws2-msk-producer"));
             boolean hasRegionMessage = res2.stream()
                     .anyMatch(r -> r.getMessage().stream().anyMatch(msg -> msg.contains("region")));
             Assertions.assertTrue(down, "liveness check");
diff --git a/components/camel-aws/camel-aws2-msk/src/test/java/org/apache/camel/component/aws2/msk/MSK2HealthCheckProfileCredsTest.java b/components/camel-aws/camel-aws2-msk/src/test/java/org/apache/camel/component/aws2/msk/MSK2ProducerHealthCheckStaticCredsTest.java
similarity index 87%
rename from components/camel-aws/camel-aws2-msk/src/test/java/org/apache/camel/component/aws2/msk/MSK2HealthCheckProfileCredsTest.java
rename to components/camel-aws/camel-aws2-msk/src/test/java/org/apache/camel/component/aws2/msk/MSK2ProducerHealthCheckStaticCredsTest.java
index e8bfa1ac3ef..6e5b9b83666 100644
--- a/components/camel-aws/camel-aws2-msk/src/test/java/org/apache/camel/component/aws2/msk/MSK2HealthCheckProfileCredsTest.java
+++ b/components/camel-aws/camel-aws2-msk/src/test/java/org/apache/camel/component/aws2/msk/MSK2ProducerHealthCheckStaticCredsTest.java
@@ -27,16 +27,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 MSK2HealthCheckProfileCredsTest extends CamelTestSupport {
-
-    private static final Logger LOG = LoggerFactory.getLogger(MSK2HealthCheckProfileCredsTest.class);
+public class MSK2ProducerHealthCheckStaticCredsTest extends CamelTestSupport {
 
     CamelContext context;
 
@@ -72,9 +67,7 @@ public class MSK2HealthCheckProfileCredsTest 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);
         boolean up = res.stream().allMatch(r -> r.getState().equals(HealthCheck.State.UP));
         Assertions.assertTrue(up, "liveness check");
@@ -84,9 +77,7 @@ public class MSK2HealthCheckProfileCredsTest extends CamelTestSupport {
             Collection<HealthCheck.Result> res2 = HealthCheckHelper.invokeReadiness(context);
             boolean down = res2.stream().allMatch(r -> r.getState().equals(HealthCheck.State.DOWN));
             boolean containsAws2AthenaHealthCheck = res2.stream()
-                    .filter(result -> result.getCheck().getId().startsWith("aws2-msk-client"))
-                    .findAny()
-                    .isPresent();
+                    .anyMatch(result -> result.getCheck().getId().startsWith("aws2-msk-producer"));
             boolean hasRegionMessage = res2.stream()
                     .anyMatch(r -> r.getMessage().stream().anyMatch(msg -> msg.contains("region")));
             Assertions.assertTrue(down, "liveness check");


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

Posted by da...@apache.org.
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 76cee9c4960e65d1dd1a0741000a25f6f766e536
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri Jul 28 10:11:30 2023 +0200

    CAMEL-19645: camel-aws - producer health check
---
 .../aws2/sns/Sns2ComponentConfigurer.java          | 18 +++++++++++++
 .../apache/camel/component/aws2/sns/aws2-sns.json  |  7 +++--
 .../camel/component/aws2/sns/Sns2Component.java    |  5 ++--
 .../camel/component/aws2/sns/Sns2Endpoint.java     | 23 ++++------------
 .../camel/component/aws2/sns/Sns2Producer.java     | 31 ++++++++++++++++++++++
 ...althCheck.java => Sns2ProducerHealthCheck.java} |  9 +++----
 ...> Sns2ProducerHealthCheckProfileCredsTest.java} | 13 ++-------
 ...=> Sns2ProducerHealthCheckStaticCredsTest.java} | 13 ++-------
 8 files changed, 69 insertions(+), 50 deletions(-)

diff --git a/components/camel-aws/camel-aws2-sns/src/generated/java/org/apache/camel/component/aws2/sns/Sns2ComponentConfigurer.java b/components/camel-aws/camel-aws2-sns/src/generated/java/org/apache/camel/component/aws2/sns/Sns2ComponentConfigurer.java
index e18916ece0c..7f996f8035e 100644
--- a/components/camel-aws/camel-aws2-sns/src/generated/java/org/apache/camel/component/aws2/sns/Sns2ComponentConfigurer.java
+++ b/components/camel-aws/camel-aws2-sns/src/generated/java/org/apache/camel/component/aws2/sns/Sns2ComponentConfigurer.java
@@ -37,6 +37,12 @@ public class Sns2ComponentConfigurer extends PropertyConfigurerSupport implement
         case "autowiredenabled":
         case "autowiredEnabled": target.setAutowiredEnabled(property(camelContext, boolean.class, value)); return true;
         case "configuration": target.setConfiguration(property(camelContext, org.apache.camel.component.aws2.sns.Sns2Configuration.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 "kmsmasterkeyid":
         case "kmsMasterKeyId": getOrCreateConfiguration(target).setKmsMasterKeyId(property(camelContext, java.lang.String.class, value)); return true;
         case "lazystartproducer":
@@ -97,6 +103,12 @@ public class Sns2ComponentConfigurer extends PropertyConfigurerSupport implement
         case "autowiredenabled":
         case "autowiredEnabled": return boolean.class;
         case "configuration": return org.apache.camel.component.aws2.sns.Sns2Configuration.class;
+        case "healthcheckconsumerenabled":
+        case "healthCheckConsumerEnabled": return boolean.class;
+        case "healthcheckenabled":
+        case "healthCheckEnabled": return boolean.class;
+        case "healthcheckproducerenabled":
+        case "healthCheckProducerEnabled": return boolean.class;
         case "kmsmasterkeyid":
         case "kmsMasterKeyId": return java.lang.String.class;
         case "lazystartproducer":
@@ -153,6 +165,12 @@ public class Sns2ComponentConfigurer extends PropertyConfigurerSupport implement
         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 "kmsmasterkeyid":
         case "kmsMasterKeyId": return getOrCreateConfiguration(target).getKmsMasterKeyId();
         case "lazystartproducer":
diff --git a/components/camel-aws/camel-aws2-sns/src/generated/resources/org/apache/camel/component/aws2/sns/aws2-sns.json b/components/camel-aws/camel-aws2-sns/src/generated/resources/org/apache/camel/component/aws2/sns/aws2-sns.json
index a83fbde968a..8021e8c19e0 100644
--- a/components/camel-aws/camel-aws2-sns/src/generated/resources/org/apache/camel/component/aws2/sns/aws2-sns.json
+++ b/components/camel-aws/camel-aws2-sns/src/generated/resources/org/apache/camel/component/aws2/sns/aws2-sns.json
@@ -46,8 +46,11 @@
     "useDefaultCredentialsProvider": { "index": 21, "kind": "property", "displayName": "Use Default 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.sns.Sns2Configuration", "configurationField": "configuration", "description": "Set whether the SNS client should expect to load credential [...]
     "useProfileCredentialsProvider": { "index": 22, "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.sns.Sns2Configuration", "configurationField": "configuration", "description": "Set whether the SNS client should expect to load credential [...]
     "autowiredEnabled": { "index": 23, "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": 24, "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.sns.Sns2Configuration", "configurationField": "configuration", "description": "Amazon AWS Access Key" },
-    "secretKey": { "index": 25, "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.sns.Sns2Configuration", "configurationField": "configuration", "description": "Amazon AWS Secret Key" }
+    "healthCheckConsumerEnabled": { "index": 24, "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": 25, "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": 26, "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": 27, "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.sns.Sns2Configuration", "configurationField": "configuration", "description": "Amazon AWS Access Key" },
+    "secretKey": { "index": 28, "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.sns.Sns2Configuration", "configurationField": "configuration", "description": "Amazon AWS Secret Key" }
   },
   "headers": {
     "CamelAwsSnsMessageId": { "index": 0, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The Amazon SNS message ID.", "constantName": "org.apache.camel.component.aws2.sns.Sns2Constants#MESSAGE_ID" },
diff --git a/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/Sns2Component.java b/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/Sns2Component.java
index 5e51d0ace36..f2930206b77 100644
--- a/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/Sns2Component.java
+++ b/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/Sns2Component.java
@@ -23,13 +23,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;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import software.amazon.awssdk.regions.Region;
 
 @Component("aws2-sns")
-public class Sns2Component extends DefaultComponent {
+public class Sns2Component extends HealthCheckComponent {
 
     private static final Logger LOG = LoggerFactory.getLogger(Sns2Component.class);
 
@@ -42,7 +42,6 @@ public class Sns2Component extends DefaultComponent {
 
     public Sns2Component(CamelContext context) {
         super(context);
-
     }
 
     @Override
diff --git a/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/Sns2Endpoint.java b/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/Sns2Endpoint.java
index 654d94efbb4..e726a427b70 100644
--- a/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/Sns2Endpoint.java
+++ b/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/Sns2Endpoint.java
@@ -27,8 +27,6 @@ import org.apache.camel.Consumer;
 import org.apache.camel.Processor;
 import org.apache.camel.Producer;
 import org.apache.camel.component.aws2.sns.client.Sns2ClientFactory;
-import org.apache.camel.health.HealthCheckHelper;
-import org.apache.camel.impl.health.ComponentsHealthCheckRepository;
 import org.apache.camel.spi.HeaderFilterStrategy;
 import org.apache.camel.spi.HeaderFilterStrategyAware;
 import org.apache.camel.spi.Metadata;
@@ -62,9 +60,6 @@ public class Sns2Endpoint extends DefaultEndpoint implements HeaderFilterStrateg
 
     private static final Logger LOG = LoggerFactory.getLogger(Sns2Endpoint.class);
 
-    private ComponentsHealthCheckRepository healthCheckRepository;
-    private Sns2HealthCheck clientHealthCheck;
-
     private SnsClient snsClient;
 
     @UriPath(description = "Topic name or ARN")
@@ -103,6 +98,11 @@ public class Sns2Endpoint extends DefaultEndpoint implements HeaderFilterStrateg
         return new Sns2Producer(this);
     }
 
+    @Override
+    public Sns2Component getComponent() {
+        return (Sns2Component) super.getComponent();
+    }
+
     @Override
     public void doInit() throws Exception {
         super.doInit();
@@ -114,15 +114,6 @@ public class Sns2Endpoint extends DefaultEndpoint implements HeaderFilterStrateg
             headerFilterStrategy = new Sns2HeaderFilterStrategy();
         }
 
-        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 Sns2HealthCheck(this, getId());
-            // healthCheckRepository.addHealthCheck(clientHealthCheck);
-        }
-
         if (configuration.getTopicArn() == null) {
             try {
                 String nextToken = null;
@@ -208,10 +199,6 @@ public class Sns2Endpoint extends DefaultEndpoint implements HeaderFilterStrateg
             }
         }
 
-        if (healthCheckRepository != null && clientHealthCheck != null) {
-            healthCheckRepository.removeHealthCheck(clientHealthCheck);
-            clientHealthCheck = null;
-        }
         super.doStop();
     }
 
diff --git a/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/Sns2Producer.java b/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/Sns2Producer.java
index b09f95772f1..d96cbdd613a 100644
--- a/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/Sns2Producer.java
+++ b/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/Sns2Producer.java
@@ -28,6 +28,9 @@ import java.util.stream.Collectors;
 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.spi.HeaderFilterStrategy;
 import org.apache.camel.support.DefaultProducer;
 import org.apache.camel.util.ObjectHelper;
@@ -48,6 +51,8 @@ public class Sns2Producer extends DefaultProducer {
     private static final Logger LOG = LoggerFactory.getLogger(Sns2Producer.class);
 
     private transient String snsProducerToString;
+    private HealthCheck producerHealthCheck;
+    private WritableHealthCheckRepository healthCheckRepository;
 
     public Sns2Producer(Endpoint endpoint) {
         super(endpoint);
@@ -183,4 +188,30 @@ public class Sns2Producer extends DefaultProducer {
     public static Message getMessageForResponse(final Exchange exchange) {
         return exchange.getMessage();
     }
+
+    @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 Sns2ProducerHealthCheck(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-sns/src/main/java/org/apache/camel/component/aws2/sns/Sns2HealthCheck.java b/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/Sns2ProducerHealthCheck.java
similarity index 91%
rename from components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/Sns2HealthCheck.java
rename to components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/Sns2ProducerHealthCheck.java
index 9401f1c3a30..ad587f314a3 100644
--- a/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/Sns2HealthCheck.java
+++ b/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/Sns2ProducerHealthCheck.java
@@ -24,18 +24,17 @@ import software.amazon.awssdk.awscore.exception.AwsServiceException;
 import software.amazon.awssdk.regions.Region;
 import software.amazon.awssdk.services.sns.SnsClient;
 
-public class Sns2HealthCheck extends AbstractHealthCheck {
+public class Sns2ProducerHealthCheck extends AbstractHealthCheck {
 
     private final Sns2Endpoint sns2Endpoint;
 
-    public Sns2HealthCheck(Sns2Endpoint sns2Endpoint, String clientId) {
-        super("camel", "aws2-sns-client-" + clientId);
+    public Sns2ProducerHealthCheck(Sns2Endpoint sns2Endpoint, String clientId) {
+        super("camel", "aws2-sns-producer-" + clientId);
         this.sns2Endpoint = sns2Endpoint;
     }
 
     @Override
     protected void doCall(HealthCheckResultBuilder builder, Map<String, Object> options) {
-
         Sns2Configuration configuration = sns2Endpoint.getConfiguration();
         try {
             if (!SnsClient.serviceMetadata().regions().contains(Region.of(configuration.getRegion()))) {
@@ -54,8 +53,8 @@ public class Sns2HealthCheck extends AbstractHealthCheck {
             builder.down();
             return;
         }
-        builder.up();
 
+        builder.up();
     }
 
 }
diff --git a/components/camel-aws/camel-aws2-sns/src/test/java/org/apache/camel/component/aws2/sns/Sns2HealthCheckProfileCredsTest.java b/components/camel-aws/camel-aws2-sns/src/test/java/org/apache/camel/component/aws2/sns/Sns2ProducerHealthCheckProfileCredsTest.java
similarity index 87%
rename from components/camel-aws/camel-aws2-sns/src/test/java/org/apache/camel/component/aws2/sns/Sns2HealthCheckProfileCredsTest.java
rename to components/camel-aws/camel-aws2-sns/src/test/java/org/apache/camel/component/aws2/sns/Sns2ProducerHealthCheckProfileCredsTest.java
index dc33d1e97c6..766387d5fe8 100644
--- a/components/camel-aws/camel-aws2-sns/src/test/java/org/apache/camel/component/aws2/sns/Sns2HealthCheckProfileCredsTest.java
+++ b/components/camel-aws/camel-aws2-sns/src/test/java/org/apache/camel/component/aws2/sns/Sns2ProducerHealthCheckProfileCredsTest.java
@@ -27,16 +27,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 Sns2HealthCheckProfileCredsTest extends CamelTestSupport {
-
-    private static final Logger LOG = LoggerFactory.getLogger(Sns2HealthCheckProfileCredsTest.class);
+public class Sns2ProducerHealthCheckProfileCredsTest extends CamelTestSupport {
 
     CamelContext context;
 
@@ -72,9 +67,7 @@ public class Sns2HealthCheckProfileCredsTest 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);
         boolean up = res.stream().allMatch(r -> r.getState().equals(HealthCheck.State.UP));
         Assertions.assertTrue(up, "liveness check");
@@ -84,9 +77,7 @@ public class Sns2HealthCheckProfileCredsTest extends CamelTestSupport {
             Collection<HealthCheck.Result> res2 = HealthCheckHelper.invokeReadiness(context);
             boolean down = res2.stream().allMatch(r -> r.getState().equals(HealthCheck.State.DOWN));
             boolean containsAws2AthenaHealthCheck = res2.stream()
-                    .filter(result -> result.getCheck().getId().startsWith("aws2-sns-client"))
-                    .findAny()
-                    .isPresent();
+                    .anyMatch(result -> result.getCheck().getId().startsWith("aws2-sns-producer"));
             boolean hasRegionMessage = res2.stream()
                     .anyMatch(r -> r.getMessage().stream().anyMatch(msg -> msg.contains("region")));
             Assertions.assertTrue(down, "liveness check");
diff --git a/components/camel-aws/camel-aws2-sns/src/test/java/org/apache/camel/component/aws2/sns/Sns2HealthCheckStaticCredsTest.java b/components/camel-aws/camel-aws2-sns/src/test/java/org/apache/camel/component/aws2/sns/Sns2ProducerHealthCheckStaticCredsTest.java
similarity index 87%
rename from components/camel-aws/camel-aws2-sns/src/test/java/org/apache/camel/component/aws2/sns/Sns2HealthCheckStaticCredsTest.java
rename to components/camel-aws/camel-aws2-sns/src/test/java/org/apache/camel/component/aws2/sns/Sns2ProducerHealthCheckStaticCredsTest.java
index 3e3f93f3230..d55d6c2d944 100644
--- a/components/camel-aws/camel-aws2-sns/src/test/java/org/apache/camel/component/aws2/sns/Sns2HealthCheckStaticCredsTest.java
+++ b/components/camel-aws/camel-aws2-sns/src/test/java/org/apache/camel/component/aws2/sns/Sns2ProducerHealthCheckStaticCredsTest.java
@@ -27,16 +27,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 Sns2HealthCheckStaticCredsTest extends CamelTestSupport {
-
-    private static final Logger LOG = LoggerFactory.getLogger(Sns2HealthCheckStaticCredsTest.class);
+public class Sns2ProducerHealthCheckStaticCredsTest extends CamelTestSupport {
 
     CamelContext context;
 
@@ -72,9 +67,7 @@ public class Sns2HealthCheckStaticCredsTest 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);
         boolean up = res.stream().allMatch(r -> r.getState().equals(HealthCheck.State.UP));
         Assertions.assertTrue(up, "liveness check");
@@ -84,9 +77,7 @@ public class Sns2HealthCheckStaticCredsTest extends CamelTestSupport {
             Collection<HealthCheck.Result> res2 = HealthCheckHelper.invokeReadiness(context);
             boolean down = res2.stream().allMatch(r -> r.getState().equals(HealthCheck.State.DOWN));
             boolean containsAws2AthenaHealthCheck = res2.stream()
-                    .filter(result -> result.getCheck().getId().startsWith("aws2-sns-client"))
-                    .findAny()
-                    .isPresent();
+                    .anyMatch(result -> result.getCheck().getId().startsWith("aws2-sns-producer"));
             boolean hasRegionMessage = res2.stream()
                     .anyMatch(r -> r.getMessage().stream().anyMatch(msg -> msg.contains("region")));
             Assertions.assertTrue(down, "liveness check");


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

Posted by da...@apache.org.
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 c97b047cd18bcae560b2f799cdb4fade1b4ff5ee
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri Jul 28 10:01:25 2023 +0200

    CAMEL-19645: camel-aws - producer health check
---
 .../aws2/iam/IAM2ComponentConfigurer.java          | 18 +++++++++++++
 .../apache/camel/component/aws2/iam/aws2-iam.json  |  7 +++--
 .../camel/component/aws2/iam/IAM2Component.java    |  5 ++--
 .../camel/component/aws2/iam/IAM2Endpoint.java     | 22 ++++-----------
 .../camel/component/aws2/iam/IAM2Producer.java     | 31 ++++++++++++++++++++++
 ...althCheck.java => IAM2ProducerHealthCheck.java} |  6 ++---
 ...> IAM2ProducerHealthCheckProfileCredsTest.java} | 12 ++-------
 ...=> IAM2ProducerHealthCheckStaticCredsTest.java} | 12 ++-------
 8 files changed, 69 insertions(+), 44 deletions(-)

diff --git a/components/camel-aws/camel-aws2-iam/src/generated/java/org/apache/camel/component/aws2/iam/IAM2ComponentConfigurer.java b/components/camel-aws/camel-aws2-iam/src/generated/java/org/apache/camel/component/aws2/iam/IAM2ComponentConfigurer.java
index 5065a77b771..5d3b3d3ec22 100644
--- a/components/camel-aws/camel-aws2-iam/src/generated/java/org/apache/camel/component/aws2/iam/IAM2ComponentConfigurer.java
+++ b/components/camel-aws/camel-aws2-iam/src/generated/java/org/apache/camel/component/aws2/iam/IAM2ComponentConfigurer.java
@@ -33,6 +33,12 @@ public class IAM2ComponentConfigurer extends PropertyConfigurerSupport implement
         case "autowiredenabled":
         case "autowiredEnabled": target.setAutowiredEnabled(property(camelContext, boolean.class, value)); return true;
         case "configuration": target.setConfiguration(property(camelContext, org.apache.camel.component.aws2.iam.IAM2Configuration.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 "iamclient":
         case "iamClient": getOrCreateConfiguration(target).setIamClient(property(camelContext, software.amazon.awssdk.services.iam.IamClient.class, value)); return true;
         case "lazystartproducer":
@@ -78,6 +84,12 @@ public class IAM2ComponentConfigurer extends PropertyConfigurerSupport implement
         case "autowiredenabled":
         case "autowiredEnabled": return boolean.class;
         case "configuration": return org.apache.camel.component.aws2.iam.IAM2Configuration.class;
+        case "healthcheckconsumerenabled":
+        case "healthCheckConsumerEnabled": return boolean.class;
+        case "healthcheckenabled":
+        case "healthCheckEnabled": return boolean.class;
+        case "healthcheckproducerenabled":
+        case "healthCheckProducerEnabled": return boolean.class;
         case "iamclient":
         case "iamClient": return software.amazon.awssdk.services.iam.IamClient.class;
         case "lazystartproducer":
@@ -119,6 +131,12 @@ public class IAM2ComponentConfigurer extends PropertyConfigurerSupport implement
         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 "iamclient":
         case "iamClient": return getOrCreateConfiguration(target).getIamClient();
         case "lazystartproducer":
diff --git a/components/camel-aws/camel-aws2-iam/src/generated/resources/org/apache/camel/component/aws2/iam/aws2-iam.json b/components/camel-aws/camel-aws2-iam/src/generated/resources/org/apache/camel/component/aws2/iam/aws2-iam.json
index b78cec97329..94886c97167 100644
--- a/components/camel-aws/camel-aws2-iam/src/generated/resources/org/apache/camel/component/aws2/iam/aws2-iam.json
+++ b/components/camel-aws/camel-aws2-iam/src/generated/resources/org/apache/camel/component/aws2/iam/aws2-iam.json
@@ -38,8 +38,11 @@
     "useDefaultCredentialsProvider": { "index": 13, "kind": "property", "displayName": "Use Default 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.iam.IAM2Configuration", "configurationField": "configuration", "description": "Set whether the IAM client should expect to load credential [...]
     "useProfileCredentialsProvider": { "index": 14, "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.iam.IAM2Configuration", "configurationField": "configuration", "description": "Set whether the IAM client should expect to load credential [...]
     "autowiredEnabled": { "index": 15, "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": 16, "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.iam.IAM2Configuration", "configurationField": "configuration", "description": "Amazon AWS Access Key" },
-    "secretKey": { "index": 17, "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.iam.IAM2Configuration", "configurationField": "configuration", "description": "Amazon AWS Secret Key" }
+    "healthCheckConsumerEnabled": { "index": 16, "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": 17, "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": 18, "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": 19, "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.iam.IAM2Configuration", "configurationField": "configuration", "description": "Amazon AWS Access Key" },
+    "secretKey": { "index": 20, "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.iam.IAM2Configuration", "configurationField": "configuration", "description": "Amazon AWS Secret Key" }
   },
   "headers": {
     "CamelAwsIAMOperation": { "index": 0, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The operation we want to perform", "constantName": "org.apache.camel.component.aws2.iam.IAM2Constants#OPERATION" },
diff --git a/components/camel-aws/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/IAM2Component.java b/components/camel-aws/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/IAM2Component.java
index a381a200f28..ec7063eb115 100644
--- a/components/camel-aws/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/IAM2Component.java
+++ b/components/camel-aws/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/IAM2Component.java
@@ -22,13 +22,14 @@ 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 IAM SDK v2.
  */
 @Component("aws2-iam")
-public class IAM2Component extends DefaultComponent {
+public class IAM2Component extends HealthCheckComponent {
+
     @Metadata
     private IAM2Configuration configuration = new IAM2Configuration();
 
diff --git a/components/camel-aws/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/IAM2Endpoint.java b/components/camel-aws/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/IAM2Endpoint.java
index 55bca7e0b6a..e3bb75f7d0d 100644
--- a/components/camel-aws/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/IAM2Endpoint.java
+++ b/components/camel-aws/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/IAM2Endpoint.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.iam.client.IAM2ClientFactory;
-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.ScheduledPollEndpoint;
@@ -39,8 +37,6 @@ import software.amazon.awssdk.services.iam.IamClient;
 public class IAM2Endpoint extends ScheduledPollEndpoint {
 
     private IamClient iamClient;
-    private ComponentsHealthCheckRepository healthCheckRepository;
-    private IAM2HealthCheck clientHealthCheck;
 
     @UriParam
     private IAM2Configuration configuration;
@@ -60,6 +56,11 @@ public class IAM2Endpoint extends ScheduledPollEndpoint {
         return new IAM2Producer(this);
     }
 
+    @Override
+    public IAM2Component getComponent() {
+        return (IAM2Component) super.getComponent();
+    }
+
     @Override
     public void doStart() throws Exception {
         super.doStart();
@@ -67,14 +68,6 @@ public class IAM2Endpoint extends ScheduledPollEndpoint {
         iamClient = configuration.getIamClient() != null
                 ? configuration.getIamClient()
                 : IAM2ClientFactory.getIamClient(configuration).getIamClient();
-        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 IAM2HealthCheck(this, getId());
-            // healthCheckRepository.addHealthCheck(clientHealthCheck);
-        }
     }
 
     @Override
@@ -84,11 +77,6 @@ public class IAM2Endpoint extends ScheduledPollEndpoint {
                 iamClient.close();
             }
         }
-        if (healthCheckRepository != null && clientHealthCheck != null) {
-            healthCheckRepository.removeHealthCheck(clientHealthCheck);
-            clientHealthCheck = null;
-        }
-        super.doStop();
     }
 
     public IAM2Configuration getConfiguration() {
diff --git a/components/camel-aws/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/IAM2Producer.java b/components/camel-aws/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/IAM2Producer.java
index aea6ae53dee..0db68c6b7d3 100644
--- a/components/camel-aws/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/IAM2Producer.java
+++ b/components/camel-aws/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/IAM2Producer.java
@@ -20,6 +20,9 @@ import org.apache.camel.Endpoint;
 import org.apache.camel.Exchange;
 import org.apache.camel.InvalidPayloadException;
 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;
 import org.apache.camel.util.ObjectHelper;
 import org.apache.camel.util.URISupport;
@@ -62,6 +65,8 @@ public class IAM2Producer extends DefaultProducer {
 
     private static final Logger LOG = LoggerFactory.getLogger(IAM2Producer.class);
     private transient String iamProducerToString;
+    private HealthCheck producerHealthCheck;
+    private WritableHealthCheckRepository healthCheckRepository;
 
     public IAM2Producer(Endpoint endpoint) {
         super(endpoint);
@@ -596,4 +601,30 @@ public class IAM2Producer extends DefaultProducer {
     public static Message getMessageForResponse(final Exchange exchange) {
         return exchange.getMessage();
     }
+
+    @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 IAM2ProducerHealthCheck(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-iam/src/main/java/org/apache/camel/component/aws2/iam/IAM2HealthCheck.java b/components/camel-aws/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/IAM2ProducerHealthCheck.java
similarity index 91%
rename from components/camel-aws/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/IAM2HealthCheck.java
rename to components/camel-aws/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/IAM2ProducerHealthCheck.java
index 5ce31b27755..e0d464dc677 100644
--- a/components/camel-aws/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/IAM2HealthCheck.java
+++ b/components/camel-aws/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/IAM2ProducerHealthCheck.java
@@ -25,11 +25,11 @@ import software.amazon.awssdk.regions.Region;
 import software.amazon.awssdk.services.iam.IamClient;
 import software.amazon.awssdk.services.iam.model.ListAccessKeysRequest;
 
-public class IAM2HealthCheck extends AbstractHealthCheck {
+public class IAM2ProducerHealthCheck extends AbstractHealthCheck {
     private final IAM2Endpoint endpoint;
 
-    public IAM2HealthCheck(IAM2Endpoint endpoint, String clientId) {
-        super("camel", "aws2-iam-client-" + clientId);
+    public IAM2ProducerHealthCheck(IAM2Endpoint endpoint, String clientId) {
+        super("camel", "aws2-iam-producer-" + clientId);
         this.endpoint = endpoint;
     }
 
diff --git a/components/camel-aws/camel-aws2-iam/src/test/java/org/apache/camel/component/aws2/iam/IAM2HealthCheckProfileCredsTest.java b/components/camel-aws/camel-aws2-iam/src/test/java/org/apache/camel/component/aws2/iam/IAM2ProducerHealthCheckProfileCredsTest.java
similarity index 87%
rename from components/camel-aws/camel-aws2-iam/src/test/java/org/apache/camel/component/aws2/iam/IAM2HealthCheckProfileCredsTest.java
rename to components/camel-aws/camel-aws2-iam/src/test/java/org/apache/camel/component/aws2/iam/IAM2ProducerHealthCheckProfileCredsTest.java
index e2761ca3b2a..00aa814ff98 100644
--- a/components/camel-aws/camel-aws2-iam/src/test/java/org/apache/camel/component/aws2/iam/IAM2HealthCheckProfileCredsTest.java
+++ b/components/camel-aws/camel-aws2-iam/src/test/java/org/apache/camel/component/aws2/iam/IAM2ProducerHealthCheckProfileCredsTest.java
@@ -27,15 +27,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 IAM2HealthCheckProfileCredsTest extends CamelTestSupport {
-    private static final Logger LOG = LoggerFactory.getLogger(IAM2HealthCheckProfileCredsTest.class);
+public class IAM2ProducerHealthCheckProfileCredsTest extends CamelTestSupport {
 
     CamelContext context;
 
@@ -71,9 +67,7 @@ public class IAM2HealthCheckProfileCredsTest 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);
         boolean up = res.stream().allMatch(r -> r.getState().equals(HealthCheck.State.UP));
         Assertions.assertTrue(up, "liveness check");
@@ -83,9 +77,7 @@ public class IAM2HealthCheckProfileCredsTest extends CamelTestSupport {
             Collection<HealthCheck.Result> res2 = HealthCheckHelper.invokeReadiness(context);
             boolean down = res2.stream().allMatch(r -> r.getState().equals(HealthCheck.State.DOWN));
             boolean containsHealthCheck = res2.stream()
-                    .filter(result -> result.getCheck().getId().startsWith("aws2-iam-client"))
-                    .findAny()
-                    .isPresent();
+                    .anyMatch(result -> result.getCheck().getId().startsWith("aws2-iam-producer"));
             boolean hasRegionMessage = res2.stream()
                     .anyMatch(r -> r.getMessage().stream().anyMatch(msg -> msg.contains("region")));
             Assertions.assertTrue(down, "liveness check");
diff --git a/components/camel-aws/camel-aws2-iam/src/test/java/org/apache/camel/component/aws2/iam/IAM2HealthCheckStaticCredsTest.java b/components/camel-aws/camel-aws2-iam/src/test/java/org/apache/camel/component/aws2/iam/IAM2ProducerHealthCheckStaticCredsTest.java
similarity index 87%
rename from components/camel-aws/camel-aws2-iam/src/test/java/org/apache/camel/component/aws2/iam/IAM2HealthCheckStaticCredsTest.java
rename to components/camel-aws/camel-aws2-iam/src/test/java/org/apache/camel/component/aws2/iam/IAM2ProducerHealthCheckStaticCredsTest.java
index 91fc262ace7..dba530007f5 100644
--- a/components/camel-aws/camel-aws2-iam/src/test/java/org/apache/camel/component/aws2/iam/IAM2HealthCheckStaticCredsTest.java
+++ b/components/camel-aws/camel-aws2-iam/src/test/java/org/apache/camel/component/aws2/iam/IAM2ProducerHealthCheckStaticCredsTest.java
@@ -27,15 +27,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 IAM2HealthCheckStaticCredsTest extends CamelTestSupport {
-    private static final Logger LOG = LoggerFactory.getLogger(IAM2HealthCheckStaticCredsTest.class);
+public class IAM2ProducerHealthCheckStaticCredsTest extends CamelTestSupport {
 
     CamelContext context;
 
@@ -71,9 +67,7 @@ public class IAM2HealthCheckStaticCredsTest 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);
         boolean up = res.stream().allMatch(r -> r.getState().equals(HealthCheck.State.UP));
         Assertions.assertTrue(up, "liveness check");
@@ -83,9 +77,7 @@ public class IAM2HealthCheckStaticCredsTest extends CamelTestSupport {
             Collection<HealthCheck.Result> res2 = HealthCheckHelper.invokeReadiness(context);
             boolean down = res2.stream().allMatch(r -> r.getState().equals(HealthCheck.State.DOWN));
             boolean containsHealthCheck = res2.stream()
-                    .filter(result -> result.getCheck().getId().startsWith("aws2-iam-client"))
-                    .findAny()
-                    .isPresent();
+                    .anyMatch(result -> result.getCheck().getId().startsWith("aws2-iam-producer"));
             boolean hasRegionMessage = res2.stream()
                     .anyMatch(r -> r.getMessage().stream().anyMatch(msg -> msg.contains("region")));
             Assertions.assertTrue(down, "liveness check");


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

Posted by da...@apache.org.
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 3f1025ca572f46b1e972ec745ff621d06d090fd9
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri Jul 28 10:04:10 2023 +0200

    CAMEL-19645: camel-aws - producer health check
---
 .../aws2/lambda/Lambda2ComponentConfigurer.java    | 18 +++++++++++++
 .../camel/component/aws2/lambda/aws2-lambda.json   | 13 +++++----
 .../component/aws2/lambda/Lambda2Component.java    |  5 ++--
 .../component/aws2/lambda/Lambda2Endpoint.java     | 24 ++++-------------
 .../component/aws2/lambda/Lambda2Producer.java     | 31 ++++++++++++++++++++++
 ...hCheck.java => Lambda2ProducerHealthCheck.java} |  6 ++---
 ...ambda2ProducerHealthCheckProfileCredsTest.java} | 13 ++-------
 ...Lambda2ProducerHealthCheckStaticCredsTest.java} | 13 ++-------
 8 files changed, 72 insertions(+), 51 deletions(-)

diff --git a/components/camel-aws/camel-aws2-lambda/src/generated/java/org/apache/camel/component/aws2/lambda/Lambda2ComponentConfigurer.java b/components/camel-aws/camel-aws2-lambda/src/generated/java/org/apache/camel/component/aws2/lambda/Lambda2ComponentConfigurer.java
index 608a02e5c03..cc5102f2321 100644
--- a/components/camel-aws/camel-aws2-lambda/src/generated/java/org/apache/camel/component/aws2/lambda/Lambda2ComponentConfigurer.java
+++ b/components/camel-aws/camel-aws2-lambda/src/generated/java/org/apache/camel/component/aws2/lambda/Lambda2ComponentConfigurer.java
@@ -35,6 +35,12 @@ public class Lambda2ComponentConfigurer extends PropertyConfigurerSupport implem
         case "awslambdaclient":
         case "awsLambdaClient": getOrCreateConfiguration(target).setAwsLambdaClient(property(camelContext, software.amazon.awssdk.services.lambda.LambdaClient.class, value)); return true;
         case "configuration": target.setConfiguration(property(camelContext, org.apache.camel.component.aws2.lambda.Lambda2Configuration.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 "operation": getOrCreateConfiguration(target).setOperation(property(camelContext, org.apache.camel.component.aws2.lambda.Lambda2Operations.class, value)); return true;
@@ -80,6 +86,12 @@ public class Lambda2ComponentConfigurer extends PropertyConfigurerSupport implem
         case "awslambdaclient":
         case "awsLambdaClient": return software.amazon.awssdk.services.lambda.LambdaClient.class;
         case "configuration": return org.apache.camel.component.aws2.lambda.Lambda2Configuration.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 "operation": return org.apache.camel.component.aws2.lambda.Lambda2Operations.class;
@@ -121,6 +133,12 @@ public class Lambda2ComponentConfigurer extends PropertyConfigurerSupport implem
         case "awslambdaclient":
         case "awsLambdaClient": return getOrCreateConfiguration(target).getAwsLambdaClient();
         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 "operation": return getOrCreateConfiguration(target).getOperation();
diff --git a/components/camel-aws/camel-aws2-lambda/src/generated/resources/org/apache/camel/component/aws2/lambda/aws2-lambda.json b/components/camel-aws/camel-aws2-lambda/src/generated/resources/org/apache/camel/component/aws2/lambda/aws2-lambda.json
index 9be0f5a6cda..bfd9f891c42 100644
--- a/components/camel-aws/camel-aws2-lambda/src/generated/resources/org/apache/camel/component/aws2/lambda/aws2-lambda.json
+++ b/components/camel-aws/camel-aws2-lambda/src/generated/resources/org/apache/camel/component/aws2/lambda/aws2-lambda.json
@@ -35,11 +35,14 @@
     "useProfileCredentialsProvider": { "index": 10, "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.lambda.Lambda2Configuration", "configurationField": "configuration", "description": "Set whether the Lambda client should expect to load c [...]
     "autowiredEnabled": { "index": 11, "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  [...]
     "awsLambdaClient": { "index": 12, "kind": "property", "displayName": "Aws Lambda Client", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "software.amazon.awssdk.services.lambda.LambdaClient", "deprecated": false, "deprecationNote": "", "autowired": true, "secret": false, "configurationClass": "org.apache.camel.component.aws2.lambda.Lambda2Configuration", "configurationField": "configuration", "description": "To use a existing configured Aws [...]
-    "proxyHost": { "index": 13, "kind": "property", "displayName": "Proxy Host", "group": "proxy", "label": "proxy", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.lambda.Lambda2Configuration", "configurationField": "configuration", "description": "To define a proxy host when instantiating the Lambda client" },
-    "proxyPort": { "index": 14, "kind": "property", "displayName": "Proxy Port", "group": "proxy", "label": "proxy", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.lambda.Lambda2Configuration", "configurationField": "configuration", "description": "To define a proxy port when instantiating the Lambda client" },
-    "proxyProtocol": { "index": 15, "kind": "property", "displayName": "Proxy Protocol", "group": "proxy", "label": "proxy", "required": false, "type": "object", "javaType": "software.amazon.awssdk.core.Protocol", "enum": [ "HTTP", "HTTPS" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "HTTPS", "configurationClass": "org.apache.camel.component.aws2.lambda.Lambda2Configuration", "configurationField": "configuration", "description": "To define a proxy protocol [...]
-    "accessKey": { "index": 16, "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.lambda.Lambda2Configuration", "configurationField": "configuration", "description": "Amazon AWS Access Key" },
-    "secretKey": { "index": 17, "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.lambda.Lambda2Configuration", "configurationField": "configuration", "description": "Amazon AWS Secret Key" }
+    "healthCheckConsumerEnabled": { "index": 13, "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": 14, "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": 15, "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" },
+    "proxyHost": { "index": 16, "kind": "property", "displayName": "Proxy Host", "group": "proxy", "label": "proxy", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.lambda.Lambda2Configuration", "configurationField": "configuration", "description": "To define a proxy host when instantiating the Lambda client" },
+    "proxyPort": { "index": 17, "kind": "property", "displayName": "Proxy Port", "group": "proxy", "label": "proxy", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.lambda.Lambda2Configuration", "configurationField": "configuration", "description": "To define a proxy port when instantiating the Lambda client" },
+    "proxyProtocol": { "index": 18, "kind": "property", "displayName": "Proxy Protocol", "group": "proxy", "label": "proxy", "required": false, "type": "object", "javaType": "software.amazon.awssdk.core.Protocol", "enum": [ "HTTP", "HTTPS" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "HTTPS", "configurationClass": "org.apache.camel.component.aws2.lambda.Lambda2Configuration", "configurationField": "configuration", "description": "To define a proxy protocol [...]
+    "accessKey": { "index": 19, "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.lambda.Lambda2Configuration", "configurationField": "configuration", "description": "Amazon AWS Access Key" },
+    "secretKey": { "index": 20, "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.lambda.Lambda2Configuration", "configurationField": "configuration", "description": "Amazon AWS Secret Key" }
   },
   "headers": {
     "CamelAwsLambdaOperation": { "index": 0, "kind": "header", "displayName": "", "group": "all", "label": "all", "required": true, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The operation we want to perform. Override operation passed as query parameter", "constantName": "org.apache.camel.component.aws2.lambda.Lambda2Constants#OPERATION" },
diff --git a/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Component.java b/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Component.java
index e043ce35d9a..7e0a60d3441 100644
--- a/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Component.java
+++ b/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Component.java
@@ -22,13 +22,14 @@ 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 Lambda SDK v2.
  */
 @Component("aws2-lambda")
-public class Lambda2Component extends DefaultComponent {
+public class Lambda2Component extends HealthCheckComponent {
+
     @Metadata
     private Lambda2Configuration configuration = new Lambda2Configuration();
 
diff --git a/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Endpoint.java b/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Endpoint.java
index 594f09907c8..035c46f18d2 100644
--- a/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Endpoint.java
+++ b/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Endpoint.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.lambda.client.Lambda2ClientFactory;
-import org.apache.camel.health.HealthCheckHelper;
-import org.apache.camel.impl.health.ComponentsHealthCheckRepository;
 import org.apache.camel.spi.Metadata;
 import org.apache.camel.spi.UriEndpoint;
 import org.apache.camel.spi.UriParam;
@@ -42,9 +40,6 @@ public class Lambda2Endpoint extends DefaultEndpoint {
 
     private LambdaClient awsLambdaClient;
 
-    private ComponentsHealthCheckRepository healthCheckRepository;
-    private Lambda2ClientHealthCheck clientHealthCheck;
-
     @UriPath
     @Metadata(required = true)
     private String function;
@@ -66,6 +61,11 @@ public class Lambda2Endpoint extends DefaultEndpoint {
         return new Lambda2Producer(this);
     }
 
+    @Override
+    public Lambda2Component getComponent() {
+        return (Lambda2Component) super.getComponent();
+    }
+
     public String getFunction() {
         return function;
     }
@@ -83,24 +83,10 @@ public class Lambda2Endpoint extends DefaultEndpoint {
         awsLambdaClient = configuration.getAwsLambdaClient() != null
                 ? configuration.getAwsLambdaClient()
                 : Lambda2ClientFactory.getLambdaClient(configuration).getLambdaClient();
-
-        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 Lambda2ClientHealthCheck(this, getId());
-            // healthCheckRepository.addHealthCheck(clientHealthCheck);
-        }
     }
 
     @Override
     public void doStop() throws Exception {
-        if (healthCheckRepository != null && clientHealthCheck != null) {
-            healthCheckRepository.removeHealthCheck(clientHealthCheck);
-            clientHealthCheck = null;
-        }
-
         if (ObjectHelper.isEmpty(configuration.getAwsLambdaClient())) {
             if (awsLambdaClient != null) {
                 awsLambdaClient.close();
diff --git a/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Producer.java b/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Producer.java
index f6b3e22a710..0153e72af16 100644
--- a/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Producer.java
+++ b/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Producer.java
@@ -27,6 +27,9 @@ import org.apache.camel.Endpoint;
 import org.apache.camel.Exchange;
 import org.apache.camel.InvalidPayloadException;
 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;
 import org.apache.camel.util.CastUtils;
 import org.apache.camel.util.ObjectHelper;
@@ -85,6 +88,9 @@ public class Lambda2Producer extends DefaultProducer {
 
     private static final Logger LOG = LoggerFactory.getLogger(Lambda2Producer.class);
 
+    private HealthCheck producerHealthCheck;
+    private WritableHealthCheckRepository healthCheckRepository;
+
     public Lambda2Producer(final Endpoint endpoint) {
         super(endpoint);
     }
@@ -742,4 +748,29 @@ public class Lambda2Producer extends DefaultProducer {
         return exchange.getMessage();
     }
 
+    @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 Lambda2ProducerHealthCheck(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-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2ClientHealthCheck.java b/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2ProducerHealthCheck.java
similarity index 92%
rename from components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2ClientHealthCheck.java
rename to components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2ProducerHealthCheck.java
index 902f856042a..4b067a4725e 100644
--- a/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2ClientHealthCheck.java
+++ b/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2ProducerHealthCheck.java
@@ -27,12 +27,12 @@ import software.amazon.awssdk.regions.Region;
 import software.amazon.awssdk.services.lambda.LambdaClient;
 import software.amazon.awssdk.services.lambda.model.ListFunctionsRequest;
 
-public class Lambda2ClientHealthCheck extends AbstractHealthCheck {
+public class Lambda2ProducerHealthCheck extends AbstractHealthCheck {
 
     private final Lambda2Endpoint lambda2Endpoint;
 
-    public Lambda2ClientHealthCheck(Lambda2Endpoint lambda2Endpoint, String clientId) {
-        super("camel", "aws2-lambda-client-" + clientId);
+    public Lambda2ProducerHealthCheck(Lambda2Endpoint lambda2Endpoint, String clientId) {
+        super("camel", "aws2-lambda-producer-" + clientId);
         this.lambda2Endpoint = lambda2Endpoint;
     }
 
diff --git a/components/camel-aws/camel-aws2-lambda/src/test/java/org/apache/camel/component/aws2/lambda/Lambda2ClientHealthCheckProfileCredsTest.java b/components/camel-aws/camel-aws2-lambda/src/test/java/org/apache/camel/component/aws2/lambda/Lambda2ProducerHealthCheckProfileCredsTest.java
similarity index 87%
rename from components/camel-aws/camel-aws2-lambda/src/test/java/org/apache/camel/component/aws2/lambda/Lambda2ClientHealthCheckProfileCredsTest.java
rename to components/camel-aws/camel-aws2-lambda/src/test/java/org/apache/camel/component/aws2/lambda/Lambda2ProducerHealthCheckProfileCredsTest.java
index a518ff3570c..71d0469958e 100644
--- a/components/camel-aws/camel-aws2-lambda/src/test/java/org/apache/camel/component/aws2/lambda/Lambda2ClientHealthCheckProfileCredsTest.java
+++ b/components/camel-aws/camel-aws2-lambda/src/test/java/org/apache/camel/component/aws2/lambda/Lambda2ProducerHealthCheckProfileCredsTest.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 Lambda2ClientHealthCheckProfileCredsTest extends CamelTestSupport {
-
-    private static final Logger LOG = LoggerFactory.getLogger(Lambda2ClientHealthCheckProfileCredsTest.class);
+public class Lambda2ProducerHealthCheckProfileCredsTest extends CamelTestSupport {
 
     CamelContext context;
 
@@ -73,9 +68,7 @@ public class Lambda2ClientHealthCheckProfileCredsTest 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);
         boolean up = res.stream().allMatch(r -> r.getState().equals(HealthCheck.State.UP));
         Assertions.assertTrue(up, "liveness check");
@@ -85,9 +78,7 @@ public class Lambda2ClientHealthCheckProfileCredsTest extends CamelTestSupport {
             Collection<HealthCheck.Result> res2 = HealthCheckHelper.invokeReadiness(context);
             boolean down = res2.stream().allMatch(r -> r.getState().equals(HealthCheck.State.DOWN));
             boolean containsAws2LambdaHealthCheck = res2.stream()
-                    .filter(result -> result.getCheck().getId().startsWith("aws2-lambda-client"))
-                    .findAny()
-                    .isPresent();
+                    .anyMatch(result -> result.getCheck().getId().startsWith("aws2-lambda-producer"));
             boolean hasRegionMessage = res2.stream()
                     .anyMatch(r -> r.getMessage().stream().anyMatch(msg -> msg.contains("region")));
             Assertions.assertTrue(down, "liveness check");
diff --git a/components/camel-aws/camel-aws2-lambda/src/test/java/org/apache/camel/component/aws2/lambda/Lambda2ClientHealthCheckStaticCredsTest.java b/components/camel-aws/camel-aws2-lambda/src/test/java/org/apache/camel/component/aws2/lambda/Lambda2ProducerHealthCheckStaticCredsTest.java
similarity index 87%
rename from components/camel-aws/camel-aws2-lambda/src/test/java/org/apache/camel/component/aws2/lambda/Lambda2ClientHealthCheckStaticCredsTest.java
rename to components/camel-aws/camel-aws2-lambda/src/test/java/org/apache/camel/component/aws2/lambda/Lambda2ProducerHealthCheckStaticCredsTest.java
index 594a35d0ac6..643060fc7b0 100644
--- a/components/camel-aws/camel-aws2-lambda/src/test/java/org/apache/camel/component/aws2/lambda/Lambda2ClientHealthCheckStaticCredsTest.java
+++ b/components/camel-aws/camel-aws2-lambda/src/test/java/org/apache/camel/component/aws2/lambda/Lambda2ProducerHealthCheckStaticCredsTest.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 Lambda2ClientHealthCheckStaticCredsTest extends CamelTestSupport {
-
-    private static final Logger LOG = LoggerFactory.getLogger(Lambda2ClientHealthCheckStaticCredsTest.class);
+public class Lambda2ProducerHealthCheckStaticCredsTest extends CamelTestSupport {
 
     CamelContext context;
 
@@ -73,9 +68,7 @@ public class Lambda2ClientHealthCheckStaticCredsTest 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);
         boolean up = res.stream().allMatch(r -> r.getState().equals(HealthCheck.State.UP));
         Assertions.assertTrue(up, "liveness check");
@@ -85,9 +78,7 @@ public class Lambda2ClientHealthCheckStaticCredsTest extends CamelTestSupport {
             Collection<HealthCheck.Result> res2 = HealthCheckHelper.invokeReadiness(context);
             boolean down = res2.stream().allMatch(r -> r.getState().equals(HealthCheck.State.DOWN));
             boolean containsAws2LambdaHealthCheck = res2.stream()
-                    .filter(result -> result.getCheck().getId().startsWith("aws2-lambda-client"))
-                    .findAny()
-                    .isPresent();
+                    .anyMatch(result -> result.getCheck().getId().startsWith("aws2-lambda-producer"));
             boolean hasRegionMessage = res2.stream()
                     .anyMatch(r -> r.getMessage().stream().anyMatch(msg -> msg.contains("region")));
             Assertions.assertTrue(down, "liveness check");


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

Posted by da...@apache.org.
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 748bace887375fba9abb4994fa5ffa98fdd09028
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri Jul 28 10:21:54 2023 +0200

    CAMEL-19645: camel-aws - producer health check
---
 .../apache/camel/catalog/components/aws2-cw.json   |  7 ++-
 .../apache/camel/catalog/components/aws2-ddb.json  |  7 ++-
 .../apache/camel/catalog/components/aws2-ec2.json  |  5 +-
 .../apache/camel/catalog/components/aws2-ecs.json  |  7 ++-
 .../apache/camel/catalog/components/aws2-eks.json  |  7 ++-
 .../camel/catalog/components/aws2-eventbridge.json |  7 ++-
 .../apache/camel/catalog/components/aws2-iam.json  |  7 ++-
 .../camel/catalog/components/aws2-lambda.json      | 13 ++++--
 .../apache/camel/catalog/components/aws2-mq.json   |  7 ++-
 .../apache/camel/catalog/components/aws2-msk.json  |  7 ++-
 .../apache/camel/catalog/components/aws2-ses.json  |  7 ++-
 .../apache/camel/catalog/components/aws2-sns.json  |  7 ++-
 .../camel/catalog/components/aws2-translate.json   |  7 ++-
 .../dsl/Aws2CwComponentBuilderFactory.java         | 53 ++++++++++++++++++++++
 .../dsl/Aws2DdbComponentBuilderFactory.java        | 53 ++++++++++++++++++++++
 .../dsl/Aws2Ec2ComponentBuilderFactory.java        | 53 ++++++++++++++++++++++
 .../dsl/Aws2EcsComponentBuilderFactory.java        | 53 ++++++++++++++++++++++
 .../dsl/Aws2EksComponentBuilderFactory.java        | 53 ++++++++++++++++++++++
 .../Aws2EventbridgeComponentBuilderFactory.java    | 53 ++++++++++++++++++++++
 .../dsl/Aws2IamComponentBuilderFactory.java        | 53 ++++++++++++++++++++++
 .../dsl/Aws2LambdaComponentBuilderFactory.java     | 53 ++++++++++++++++++++++
 .../dsl/Aws2MqComponentBuilderFactory.java         | 53 ++++++++++++++++++++++
 .../dsl/Aws2MskComponentBuilderFactory.java        | 53 ++++++++++++++++++++++
 .../dsl/Aws2SesComponentBuilderFactory.java        | 53 ++++++++++++++++++++++
 .../dsl/Aws2SnsComponentBuilderFactory.java        | 53 ++++++++++++++++++++++
 .../dsl/Aws2TranslateComponentBuilderFactory.java  | 53 ++++++++++++++++++++++
 26 files changed, 756 insertions(+), 28 deletions(-)

diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-cw.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-cw.json
index 51ee300af56..212d6245ee4 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-cw.json
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/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/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-ddb.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-ddb.json
index c41957010e9..9f50f17e306 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-ddb.json
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/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/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-ec2.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-ec2.json
index d85692988d8..9e4ed24b199 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-ec2.json
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-ec2.json
@@ -39,7 +39,10 @@
     "uriEndpointOverride": { "index": 14, "kind": "property", "displayName": "Uri Endpoint Override", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.ec2.AWS2EC2Configuration", "configurationField": "configuration", "description": "Set the overriding uri endpoint. This option needs to be used in combination with overrideEn [...]
     "useDefaultCredentialsProvider": { "index": 15, "kind": "property", "displayName": "Use Default 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.ec2.AWS2EC2Configuration", "configurationField": "configuration", "description": "Set whether the EC2 client should expect to load credent [...]
     "useProfileCredentialsProvider": { "index": 16, "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.ec2.AWS2EC2Configuration", "configurationField": "configuration", "description": "Set whether the EC2 client should expect to load credent [...]
-    "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  [...]
+    "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  [...]
+    "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" }
   },
   "headers": {
     "CamelAwsEC2ImageId": { "index": 0, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "An image ID of the AWS marketplace", "constantName": "org.apache.camel.component.aws2.ec2.AWS2EC2Constants#IMAGE_ID" },
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-ecs.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-ecs.json
index cf6d913192c..791e53deeb2 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-ecs.json
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-ecs.json
@@ -38,8 +38,11 @@
     "useDefaultCredentialsProvider": { "index": 13, "kind": "property", "displayName": "Use Default 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.ecs.ECS2Configuration", "configurationField": "configuration", "description": "Set whether the ECS client should expect to load credential [...]
     "useProfileCredentialsProvider": { "index": 14, "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.ecs.ECS2Configuration", "configurationField": "configuration", "description": "Set whether the ECS client should expect to load credential [...]
     "autowiredEnabled": { "index": 15, "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": 16, "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.ecs.ECS2Configuration", "configurationField": "configuration", "description": "Amazon AWS Access Key" },
-    "secretKey": { "index": 17, "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.ecs.ECS2Configuration", "configurationField": "configuration", "description": "Amazon AWS Secret Key" }
+    "healthCheckConsumerEnabled": { "index": 16, "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": 17, "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": 18, "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": 19, "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.ecs.ECS2Configuration", "configurationField": "configuration", "description": "Amazon AWS Access Key" },
+    "secretKey": { "index": 20, "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.ecs.ECS2Configuration", "configurationField": "configuration", "description": "Amazon AWS Secret Key" }
   },
   "headers": {
     "CamelAwsECSOperation": { "index": 0, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The operation we want to perform", "constantName": "org.apache.camel.component.aws2.ecs.ECS2Constants#OPERATION" },
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-eks.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-eks.json
index fea921f0b44..ec6cacc4173 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-eks.json
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-eks.json
@@ -38,8 +38,11 @@
     "useDefaultCredentialsProvider": { "index": 13, "kind": "property", "displayName": "Use Default 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.eks.EKS2Configuration", "configurationField": "configuration", "description": "Set whether the EKS client should expect to load credential [...]
     "useProfileCredentialsProvider": { "index": 14, "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.eks.EKS2Configuration", "configurationField": "configuration", "description": "Set whether the EKS client should expect to load credential [...]
     "autowiredEnabled": { "index": 15, "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": 16, "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.eks.EKS2Configuration", "configurationField": "configuration", "description": "Amazon AWS Access Key" },
-    "secretKey": { "index": 17, "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.eks.EKS2Configuration", "configurationField": "configuration", "description": "Amazon AWS Secret Key" }
+    "healthCheckConsumerEnabled": { "index": 16, "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": 17, "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": 18, "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": 19, "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.eks.EKS2Configuration", "configurationField": "configuration", "description": "Amazon AWS Access Key" },
+    "secretKey": { "index": 20, "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.eks.EKS2Configuration", "configurationField": "configuration", "description": "Amazon AWS Secret Key" }
   },
   "headers": {
     "CamelAwsEKSOperation": { "index": 0, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The operation we want to perform", "constantName": "org.apache.camel.component.aws2.eks.EKS2Constants#OPERATION" },
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-eventbridge.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-eventbridge.json
index 16dc8a82822..d2aecb2457b 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-eventbridge.json
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-eventbridge.json
@@ -39,8 +39,11 @@
     "useDefaultCredentialsProvider": { "index": 14, "kind": "property", "displayName": "Use Default 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.eventbridge.EventbridgeConfiguration", "configurationField": "configuration", "description": "Set whether the Eventbridge client should ex [...]
     "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.eventbridge.EventbridgeConfiguration", "configurationField": "configuration", "description": "Set whether the Eventbridge client should ex [...]
     "autowiredEnabled": { "index": 16, "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": 17, "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.eventbridge.EventbridgeConfiguration", "configurationField": "configuration", "description": "Amazon AWS Access Key" },
-    "secretKey": { "index": 18, "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.eventbridge.EventbridgeConfiguration", "configurationField": "configuration", "description": "Amazon AWS Secret Key" }
+    "healthCheckConsumerEnabled": { "index": 17, "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": 18, "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": 19, "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": 20, "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.eventbridge.EventbridgeConfiguration", "configurationField": "configuration", "description": "Amazon AWS Access Key" },
+    "secretKey": { "index": 21, "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.eventbridge.EventbridgeConfiguration", "configurationField": "configuration", "description": "Amazon AWS Secret Key" }
   },
   "headers": {
     "CamelAwsEventbridgeOperation": { "index": 0, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The operation we want to perform", "constantName": "org.apache.camel.component.aws2.eventbridge.EventbridgeConstants#OPERATION" },
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-iam.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-iam.json
index b78cec97329..94886c97167 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-iam.json
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-iam.json
@@ -38,8 +38,11 @@
     "useDefaultCredentialsProvider": { "index": 13, "kind": "property", "displayName": "Use Default 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.iam.IAM2Configuration", "configurationField": "configuration", "description": "Set whether the IAM client should expect to load credential [...]
     "useProfileCredentialsProvider": { "index": 14, "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.iam.IAM2Configuration", "configurationField": "configuration", "description": "Set whether the IAM client should expect to load credential [...]
     "autowiredEnabled": { "index": 15, "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": 16, "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.iam.IAM2Configuration", "configurationField": "configuration", "description": "Amazon AWS Access Key" },
-    "secretKey": { "index": 17, "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.iam.IAM2Configuration", "configurationField": "configuration", "description": "Amazon AWS Secret Key" }
+    "healthCheckConsumerEnabled": { "index": 16, "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": 17, "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": 18, "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": 19, "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.iam.IAM2Configuration", "configurationField": "configuration", "description": "Amazon AWS Access Key" },
+    "secretKey": { "index": 20, "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.iam.IAM2Configuration", "configurationField": "configuration", "description": "Amazon AWS Secret Key" }
   },
   "headers": {
     "CamelAwsIAMOperation": { "index": 0, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The operation we want to perform", "constantName": "org.apache.camel.component.aws2.iam.IAM2Constants#OPERATION" },
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-lambda.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-lambda.json
index 9be0f5a6cda..bfd9f891c42 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-lambda.json
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-lambda.json
@@ -35,11 +35,14 @@
     "useProfileCredentialsProvider": { "index": 10, "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.lambda.Lambda2Configuration", "configurationField": "configuration", "description": "Set whether the Lambda client should expect to load c [...]
     "autowiredEnabled": { "index": 11, "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  [...]
     "awsLambdaClient": { "index": 12, "kind": "property", "displayName": "Aws Lambda Client", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "software.amazon.awssdk.services.lambda.LambdaClient", "deprecated": false, "deprecationNote": "", "autowired": true, "secret": false, "configurationClass": "org.apache.camel.component.aws2.lambda.Lambda2Configuration", "configurationField": "configuration", "description": "To use a existing configured Aws [...]
-    "proxyHost": { "index": 13, "kind": "property", "displayName": "Proxy Host", "group": "proxy", "label": "proxy", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.lambda.Lambda2Configuration", "configurationField": "configuration", "description": "To define a proxy host when instantiating the Lambda client" },
-    "proxyPort": { "index": 14, "kind": "property", "displayName": "Proxy Port", "group": "proxy", "label": "proxy", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.lambda.Lambda2Configuration", "configurationField": "configuration", "description": "To define a proxy port when instantiating the Lambda client" },
-    "proxyProtocol": { "index": 15, "kind": "property", "displayName": "Proxy Protocol", "group": "proxy", "label": "proxy", "required": false, "type": "object", "javaType": "software.amazon.awssdk.core.Protocol", "enum": [ "HTTP", "HTTPS" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "HTTPS", "configurationClass": "org.apache.camel.component.aws2.lambda.Lambda2Configuration", "configurationField": "configuration", "description": "To define a proxy protocol [...]
-    "accessKey": { "index": 16, "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.lambda.Lambda2Configuration", "configurationField": "configuration", "description": "Amazon AWS Access Key" },
-    "secretKey": { "index": 17, "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.lambda.Lambda2Configuration", "configurationField": "configuration", "description": "Amazon AWS Secret Key" }
+    "healthCheckConsumerEnabled": { "index": 13, "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": 14, "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": 15, "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" },
+    "proxyHost": { "index": 16, "kind": "property", "displayName": "Proxy Host", "group": "proxy", "label": "proxy", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.lambda.Lambda2Configuration", "configurationField": "configuration", "description": "To define a proxy host when instantiating the Lambda client" },
+    "proxyPort": { "index": 17, "kind": "property", "displayName": "Proxy Port", "group": "proxy", "label": "proxy", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.lambda.Lambda2Configuration", "configurationField": "configuration", "description": "To define a proxy port when instantiating the Lambda client" },
+    "proxyProtocol": { "index": 18, "kind": "property", "displayName": "Proxy Protocol", "group": "proxy", "label": "proxy", "required": false, "type": "object", "javaType": "software.amazon.awssdk.core.Protocol", "enum": [ "HTTP", "HTTPS" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "HTTPS", "configurationClass": "org.apache.camel.component.aws2.lambda.Lambda2Configuration", "configurationField": "configuration", "description": "To define a proxy protocol [...]
+    "accessKey": { "index": 19, "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.lambda.Lambda2Configuration", "configurationField": "configuration", "description": "Amazon AWS Access Key" },
+    "secretKey": { "index": 20, "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.lambda.Lambda2Configuration", "configurationField": "configuration", "description": "Amazon AWS Secret Key" }
   },
   "headers": {
     "CamelAwsLambdaOperation": { "index": 0, "kind": "header", "displayName": "", "group": "all", "label": "all", "required": true, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The operation we want to perform. Override operation passed as query parameter", "constantName": "org.apache.camel.component.aws2.lambda.Lambda2Constants#OPERATION" },
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-mq.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-mq.json
index 9c0aebec79e..ace81ddec57 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-mq.json
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-mq.json
@@ -38,8 +38,11 @@
     "useDefaultCredentialsProvider": { "index": 13, "kind": "property", "displayName": "Use Default 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.mq.MQ2Configuration", "configurationField": "configuration", "description": "Set whether the MQ client should expect to load credentials t [...]
     "useProfileCredentialsProvider": { "index": 14, "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.mq.MQ2Configuration", "configurationField": "configuration", "description": "Set whether the MQ client should expect to load credentials t [...]
     "autowiredEnabled": { "index": 15, "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": 16, "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.mq.MQ2Configuration", "configurationField": "configuration", "description": "Amazon AWS Access Key" },
-    "secretKey": { "index": 17, "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.mq.MQ2Configuration", "configurationField": "configuration", "description": "Amazon AWS Secret Key" }
+    "healthCheckConsumerEnabled": { "index": 16, "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": 17, "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": 18, "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": 19, "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.mq.MQ2Configuration", "configurationField": "configuration", "description": "Amazon AWS Access Key" },
+    "secretKey": { "index": 20, "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.mq.MQ2Configuration", "configurationField": "configuration", "description": "Amazon AWS Secret Key" }
   },
   "headers": {
     "CamelAwsMQOperation": { "index": 0, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The operation we want to perform", "constantName": "org.apache.camel.component.aws2.mq.MQ2Constants#OPERATION" },
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-msk.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-msk.json
index f0a4f3afbaf..9f6e843598c 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-msk.json
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-msk.json
@@ -38,8 +38,11 @@
     "useDefaultCredentialsProvider": { "index": 13, "kind": "property", "displayName": "Use Default 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.msk.MSK2Configuration", "configurationField": "configuration", "description": "Set whether the Kafka client should expect to load credenti [...]
     "useProfileCredentialsProvider": { "index": 14, "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.msk.MSK2Configuration", "configurationField": "configuration", "description": "Set whether the MSK client should expect to load credential [...]
     "autowiredEnabled": { "index": 15, "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": 16, "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.msk.MSK2Configuration", "configurationField": "configuration", "description": "Amazon AWS Access Key" },
-    "secretKey": { "index": 17, "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.msk.MSK2Configuration", "configurationField": "configuration", "description": "Amazon AWS Secret Key" }
+    "healthCheckConsumerEnabled": { "index": 16, "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": 17, "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": 18, "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": 19, "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.msk.MSK2Configuration", "configurationField": "configuration", "description": "Amazon AWS Access Key" },
+    "secretKey": { "index": 20, "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.msk.MSK2Configuration", "configurationField": "configuration", "description": "Amazon AWS Secret Key" }
   },
   "headers": {
     "CamelAwsMSKOperation": { "index": 0, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The operation we want to perform", "constantName": "org.apache.camel.component.aws2.msk.MSK2Constants#OPERATION" },
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-ses.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-ses.json
index 5cdca1ffe7f..cbc64a45e2c 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-ses.json
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-ses.json
@@ -43,8 +43,11 @@
     "useDefaultCredentialsProvider": { "index": 18, "kind": "property", "displayName": "Use Default 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.ses.Ses2Configuration", "configurationField": "configuration", "description": "Set whether the Ses client should expect to load credential [...]
     "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.ses.Ses2Configuration", "configurationField": "configuration", "description": "Set whether the SES client should expect to load credential [...]
     "autowiredEnabled": { "index": 20, "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": 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.ses.Ses2Configuration", "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.ses.Ses2Configuration", "configurationField": "configuration", "description": "Amazon AWS Secret Key" }
+    "healthCheckConsumerEnabled": { "index": 21, "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": 22, "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": 23, "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": 24, "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.ses.Ses2Configuration", "configurationField": "configuration", "description": "Amazon AWS Access Key" },
+    "secretKey": { "index": 25, "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.ses.Ses2Configuration", "configurationField": "configuration", "description": "Amazon AWS Secret Key" }
   },
   "headers": {
     "CamelAwsSesFrom": { "index": 0, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The sender's email address.", "constantName": "org.apache.camel.component.aws2.ses.Ses2Constants#FROM" },
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-sns.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-sns.json
index a83fbde968a..8021e8c19e0 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-sns.json
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-sns.json
@@ -46,8 +46,11 @@
     "useDefaultCredentialsProvider": { "index": 21, "kind": "property", "displayName": "Use Default 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.sns.Sns2Configuration", "configurationField": "configuration", "description": "Set whether the SNS client should expect to load credential [...]
     "useProfileCredentialsProvider": { "index": 22, "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.sns.Sns2Configuration", "configurationField": "configuration", "description": "Set whether the SNS client should expect to load credential [...]
     "autowiredEnabled": { "index": 23, "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": 24, "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.sns.Sns2Configuration", "configurationField": "configuration", "description": "Amazon AWS Access Key" },
-    "secretKey": { "index": 25, "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.sns.Sns2Configuration", "configurationField": "configuration", "description": "Amazon AWS Secret Key" }
+    "healthCheckConsumerEnabled": { "index": 24, "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": 25, "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": 26, "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": 27, "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.sns.Sns2Configuration", "configurationField": "configuration", "description": "Amazon AWS Access Key" },
+    "secretKey": { "index": 28, "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.sns.Sns2Configuration", "configurationField": "configuration", "description": "Amazon AWS Secret Key" }
   },
   "headers": {
     "CamelAwsSnsMessageId": { "index": 0, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The Amazon SNS message ID.", "constantName": "org.apache.camel.component.aws2.sns.Sns2Constants#MESSAGE_ID" },
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-translate.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-translate.json
index 4603ae75b0f..807946ffe31 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-translate.json
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-translate.json
@@ -41,8 +41,11 @@
     "useDefaultCredentialsProvider": { "index": 16, "kind": "property", "displayName": "Use Default 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.translate.Translate2Configuration", "configurationField": "configuration", "description": "Set whether the Translate client should expect  [...]
     "useProfileCredentialsProvider": { "index": 17, "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.translate.Translate2Configuration", "configurationField": "configuration", "description": "Set whether the Translate client should expect  [...]
     "autowiredEnabled": { "index": 18, "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": 19, "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.translate.Translate2Configuration", "configurationField": "configuration", "description": "Amazon AWS Access Key" },
-    "secretKey": { "index": 20, "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.translate.Translate2Configuration", "configurationField": "configuration", "description": "Amazon AWS Secret Key" }
+    "healthCheckConsumerEnabled": { "index": 19, "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": 20, "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": 21, "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": 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.translate.Translate2Configuration", "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.translate.Translate2Configuration", "configurationField": "configuration", "description": "Amazon AWS Secret Key" }
   },
   "headers": {
     "CamelAwsTranslateSourceLanguage": { "index": 0, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The text source language", "constantName": "org.apache.camel.component.aws2.translate.Translate2Constants#SOURCE_LANGUAGE" },
diff --git a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2CwComponentBuilderFactory.java b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2CwComponentBuilderFactory.java
index 48f89bb9a20..de8482646f5 100644
--- a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2CwComponentBuilderFactory.java
+++ b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2CwComponentBuilderFactory.java
@@ -342,6 +342,56 @@ public interface Aws2CwComponentBuilderFactory {
             doSetProperty("autowiredEnabled", autowiredEnabled);
             return this;
         }
+        /**
+         * Used for enabling or disabling all consumer based health checks from
+         * this component.
+         * 
+         * The option is a: &lt;code&gt;boolean&lt;/code&gt; type.
+         * 
+         * Default: true
+         * Group: health
+         * 
+         * @param healthCheckConsumerEnabled the value to set
+         * @return the dsl builder
+         */
+        default Aws2CwComponentBuilder healthCheckConsumerEnabled(
+                boolean healthCheckConsumerEnabled) {
+            doSetProperty("healthCheckConsumerEnabled", healthCheckConsumerEnabled);
+            return this;
+        }
+        /**
+         * Used for enabling or disabling all health checks from this component.
+         * 
+         * The option is a: &lt;code&gt;boolean&lt;/code&gt; type.
+         * 
+         * Default: true
+         * Group: health
+         * 
+         * @param healthCheckEnabled the value to set
+         * @return the dsl builder
+         */
+        default Aws2CwComponentBuilder healthCheckEnabled(
+                boolean healthCheckEnabled) {
+            doSetProperty("healthCheckEnabled", healthCheckEnabled);
+            return this;
+        }
+        /**
+         * Used for enabling or disabling all producer based health checks from
+         * this component.
+         * 
+         * The option is a: &lt;code&gt;boolean&lt;/code&gt; type.
+         * 
+         * Default: true
+         * Group: health
+         * 
+         * @param healthCheckProducerEnabled the value to set
+         * @return the dsl builder
+         */
+        default Aws2CwComponentBuilder healthCheckProducerEnabled(
+                boolean healthCheckProducerEnabled) {
+            doSetProperty("healthCheckProducerEnabled", healthCheckProducerEnabled);
+            return this;
+        }
         /**
          * Amazon AWS Access Key.
          * 
@@ -412,6 +462,9 @@ public interface Aws2CwComponentBuilderFactory {
             case "useProfileCredentialsProvider": getOrCreateConfiguration((Cw2Component) component).setUseProfileCredentialsProvider((boolean) value); return true;
             case "value": getOrCreateConfiguration((Cw2Component) component).setValue((java.lang.Double) value); return true;
             case "autowiredEnabled": ((Cw2Component) component).setAutowiredEnabled((boolean) value); return true;
+            case "healthCheckConsumerEnabled": ((Cw2Component) component).setHealthCheckConsumerEnabled((boolean) value); return true;
+            case "healthCheckEnabled": ((Cw2Component) component).setHealthCheckEnabled((boolean) value); return true;
+            case "healthCheckProducerEnabled": ((Cw2Component) component).setHealthCheckProducerEnabled((boolean) value); return true;
             case "accessKey": getOrCreateConfiguration((Cw2Component) component).setAccessKey((java.lang.String) value); return true;
             case "secretKey": getOrCreateConfiguration((Cw2Component) component).setSecretKey((java.lang.String) value); return true;
             default: return false;
diff --git a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2DdbComponentBuilderFactory.java b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2DdbComponentBuilderFactory.java
index 7c5264c11b1..ae3d8404291 100644
--- a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2DdbComponentBuilderFactory.java
+++ b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2DdbComponentBuilderFactory.java
@@ -415,6 +415,56 @@ public interface Aws2DdbComponentBuilderFactory {
             doSetProperty("autowiredEnabled", autowiredEnabled);
             return this;
         }
+        /**
+         * Used for enabling or disabling all consumer based health checks from
+         * this component.
+         * 
+         * The option is a: &lt;code&gt;boolean&lt;/code&gt; type.
+         * 
+         * Default: true
+         * Group: health
+         * 
+         * @param healthCheckConsumerEnabled the value to set
+         * @return the dsl builder
+         */
+        default Aws2DdbComponentBuilder healthCheckConsumerEnabled(
+                boolean healthCheckConsumerEnabled) {
+            doSetProperty("healthCheckConsumerEnabled", healthCheckConsumerEnabled);
+            return this;
+        }
+        /**
+         * Used for enabling or disabling all health checks from this component.
+         * 
+         * The option is a: &lt;code&gt;boolean&lt;/code&gt; type.
+         * 
+         * Default: true
+         * Group: health
+         * 
+         * @param healthCheckEnabled the value to set
+         * @return the dsl builder
+         */
+        default Aws2DdbComponentBuilder healthCheckEnabled(
+                boolean healthCheckEnabled) {
+            doSetProperty("healthCheckEnabled", healthCheckEnabled);
+            return this;
+        }
+        /**
+         * Used for enabling or disabling all producer based health checks from
+         * this component.
+         * 
+         * The option is a: &lt;code&gt;boolean&lt;/code&gt; type.
+         * 
+         * Default: true
+         * Group: health
+         * 
+         * @param healthCheckProducerEnabled the value to set
+         * @return the dsl builder
+         */
+        default Aws2DdbComponentBuilder healthCheckProducerEnabled(
+                boolean healthCheckProducerEnabled) {
+            doSetProperty("healthCheckProducerEnabled", healthCheckProducerEnabled);
+            return this;
+        }
         /**
          * Amazon AWS Access Key.
          * 
@@ -489,6 +539,9 @@ public interface Aws2DdbComponentBuilderFactory {
             case "useProfileCredentialsProvider": getOrCreateConfiguration((Ddb2Component) component).setUseProfileCredentialsProvider((boolean) value); return true;
             case "writeCapacity": getOrCreateConfiguration((Ddb2Component) component).setWriteCapacity((java.lang.Long) value); return true;
             case "autowiredEnabled": ((Ddb2Component) component).setAutowiredEnabled((boolean) value); return true;
+            case "healthCheckConsumerEnabled": ((Ddb2Component) component).setHealthCheckConsumerEnabled((boolean) value); return true;
+            case "healthCheckEnabled": ((Ddb2Component) component).setHealthCheckEnabled((boolean) value); return true;
+            case "healthCheckProducerEnabled": ((Ddb2Component) component).setHealthCheckProducerEnabled((boolean) value); return true;
             case "accessKey": getOrCreateConfiguration((Ddb2Component) component).setAccessKey((java.lang.String) value); return true;
             case "secretKey": getOrCreateConfiguration((Ddb2Component) component).setSecretKey((java.lang.String) value); return true;
             default: return false;
diff --git a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2Ec2ComponentBuilderFactory.java b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2Ec2ComponentBuilderFactory.java
index c472ac0a8c1..43a8d3a6ff6 100644
--- a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2Ec2ComponentBuilderFactory.java
+++ b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2Ec2ComponentBuilderFactory.java
@@ -352,6 +352,56 @@ public interface Aws2Ec2ComponentBuilderFactory {
             doSetProperty("autowiredEnabled", autowiredEnabled);
             return this;
         }
+        /**
+         * Used for enabling or disabling all consumer based health checks from
+         * this component.
+         * 
+         * The option is a: &lt;code&gt;boolean&lt;/code&gt; type.
+         * 
+         * Default: true
+         * Group: health
+         * 
+         * @param healthCheckConsumerEnabled the value to set
+         * @return the dsl builder
+         */
+        default Aws2Ec2ComponentBuilder healthCheckConsumerEnabled(
+                boolean healthCheckConsumerEnabled) {
+            doSetProperty("healthCheckConsumerEnabled", healthCheckConsumerEnabled);
+            return this;
+        }
+        /**
+         * Used for enabling or disabling all health checks from this component.
+         * 
+         * The option is a: &lt;code&gt;boolean&lt;/code&gt; type.
+         * 
+         * Default: true
+         * Group: health
+         * 
+         * @param healthCheckEnabled the value to set
+         * @return the dsl builder
+         */
+        default Aws2Ec2ComponentBuilder healthCheckEnabled(
+                boolean healthCheckEnabled) {
+            doSetProperty("healthCheckEnabled", healthCheckEnabled);
+            return this;
+        }
+        /**
+         * Used for enabling or disabling all producer based health checks from
+         * this component.
+         * 
+         * The option is a: &lt;code&gt;boolean&lt;/code&gt; type.
+         * 
+         * Default: true
+         * Group: health
+         * 
+         * @param healthCheckProducerEnabled the value to set
+         * @return the dsl builder
+         */
+        default Aws2Ec2ComponentBuilder healthCheckProducerEnabled(
+                boolean healthCheckProducerEnabled) {
+            doSetProperty("healthCheckProducerEnabled", healthCheckProducerEnabled);
+            return this;
+        }
     }
 
     class Aws2Ec2ComponentBuilderImpl
@@ -394,6 +444,9 @@ public interface Aws2Ec2ComponentBuilderFactory {
             case "useDefaultCredentialsProvider": getOrCreateConfiguration((AWS2EC2Component) component).setUseDefaultCredentialsProvider((boolean) value); return true;
             case "useProfileCredentialsProvider": getOrCreateConfiguration((AWS2EC2Component) component).setUseProfileCredentialsProvider((boolean) value); return true;
             case "autowiredEnabled": ((AWS2EC2Component) component).setAutowiredEnabled((boolean) value); return true;
+            case "healthCheckConsumerEnabled": ((AWS2EC2Component) component).setHealthCheckConsumerEnabled((boolean) value); return true;
+            case "healthCheckEnabled": ((AWS2EC2Component) component).setHealthCheckEnabled((boolean) value); return true;
+            case "healthCheckProducerEnabled": ((AWS2EC2Component) component).setHealthCheckProducerEnabled((boolean) value); return true;
             default: return false;
             }
         }
diff --git a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2EcsComponentBuilderFactory.java b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2EcsComponentBuilderFactory.java
index de8a897672d..375f1098736 100644
--- a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2EcsComponentBuilderFactory.java
+++ b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2EcsComponentBuilderFactory.java
@@ -319,6 +319,56 @@ public interface Aws2EcsComponentBuilderFactory {
             doSetProperty("autowiredEnabled", autowiredEnabled);
             return this;
         }
+        /**
+         * Used for enabling or disabling all consumer based health checks from
+         * this component.
+         * 
+         * The option is a: &lt;code&gt;boolean&lt;/code&gt; type.
+         * 
+         * Default: true
+         * Group: health
+         * 
+         * @param healthCheckConsumerEnabled the value to set
+         * @return the dsl builder
+         */
+        default Aws2EcsComponentBuilder healthCheckConsumerEnabled(
+                boolean healthCheckConsumerEnabled) {
+            doSetProperty("healthCheckConsumerEnabled", healthCheckConsumerEnabled);
+            return this;
+        }
+        /**
+         * Used for enabling or disabling all health checks from this component.
+         * 
+         * The option is a: &lt;code&gt;boolean&lt;/code&gt; type.
+         * 
+         * Default: true
+         * Group: health
+         * 
+         * @param healthCheckEnabled the value to set
+         * @return the dsl builder
+         */
+        default Aws2EcsComponentBuilder healthCheckEnabled(
+                boolean healthCheckEnabled) {
+            doSetProperty("healthCheckEnabled", healthCheckEnabled);
+            return this;
+        }
+        /**
+         * Used for enabling or disabling all producer based health checks from
+         * this component.
+         * 
+         * The option is a: &lt;code&gt;boolean&lt;/code&gt; type.
+         * 
+         * Default: true
+         * Group: health
+         * 
+         * @param healthCheckProducerEnabled the value to set
+         * @return the dsl builder
+         */
+        default Aws2EcsComponentBuilder healthCheckProducerEnabled(
+                boolean healthCheckProducerEnabled) {
+            doSetProperty("healthCheckProducerEnabled", healthCheckProducerEnabled);
+            return this;
+        }
         /**
          * Amazon AWS Access Key.
          * 
@@ -387,6 +437,9 @@ public interface Aws2EcsComponentBuilderFactory {
             case "useDefaultCredentialsProvider": getOrCreateConfiguration((ECS2Component) component).setUseDefaultCredentialsProvider((boolean) value); return true;
             case "useProfileCredentialsProvider": getOrCreateConfiguration((ECS2Component) component).setUseProfileCredentialsProvider((boolean) value); return true;
             case "autowiredEnabled": ((ECS2Component) component).setAutowiredEnabled((boolean) value); return true;
+            case "healthCheckConsumerEnabled": ((ECS2Component) component).setHealthCheckConsumerEnabled((boolean) value); return true;
+            case "healthCheckEnabled": ((ECS2Component) component).setHealthCheckEnabled((boolean) value); return true;
+            case "healthCheckProducerEnabled": ((ECS2Component) component).setHealthCheckProducerEnabled((boolean) value); return true;
             case "accessKey": getOrCreateConfiguration((ECS2Component) component).setAccessKey((java.lang.String) value); return true;
             case "secretKey": getOrCreateConfiguration((ECS2Component) component).setSecretKey((java.lang.String) value); return true;
             default: return false;
diff --git a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2EksComponentBuilderFactory.java b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2EksComponentBuilderFactory.java
index 632f8913644..014b44b0923 100644
--- a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2EksComponentBuilderFactory.java
+++ b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2EksComponentBuilderFactory.java
@@ -319,6 +319,56 @@ public interface Aws2EksComponentBuilderFactory {
             doSetProperty("autowiredEnabled", autowiredEnabled);
             return this;
         }
+        /**
+         * Used for enabling or disabling all consumer based health checks from
+         * this component.
+         * 
+         * The option is a: &lt;code&gt;boolean&lt;/code&gt; type.
+         * 
+         * Default: true
+         * Group: health
+         * 
+         * @param healthCheckConsumerEnabled the value to set
+         * @return the dsl builder
+         */
+        default Aws2EksComponentBuilder healthCheckConsumerEnabled(
+                boolean healthCheckConsumerEnabled) {
+            doSetProperty("healthCheckConsumerEnabled", healthCheckConsumerEnabled);
+            return this;
+        }
+        /**
+         * Used for enabling or disabling all health checks from this component.
+         * 
+         * The option is a: &lt;code&gt;boolean&lt;/code&gt; type.
+         * 
+         * Default: true
+         * Group: health
+         * 
+         * @param healthCheckEnabled the value to set
+         * @return the dsl builder
+         */
+        default Aws2EksComponentBuilder healthCheckEnabled(
+                boolean healthCheckEnabled) {
+            doSetProperty("healthCheckEnabled", healthCheckEnabled);
+            return this;
+        }
+        /**
+         * Used for enabling or disabling all producer based health checks from
+         * this component.
+         * 
+         * The option is a: &lt;code&gt;boolean&lt;/code&gt; type.
+         * 
+         * Default: true
+         * Group: health
+         * 
+         * @param healthCheckProducerEnabled the value to set
+         * @return the dsl builder
+         */
+        default Aws2EksComponentBuilder healthCheckProducerEnabled(
+                boolean healthCheckProducerEnabled) {
+            doSetProperty("healthCheckProducerEnabled", healthCheckProducerEnabled);
+            return this;
+        }
         /**
          * Amazon AWS Access Key.
          * 
@@ -387,6 +437,9 @@ public interface Aws2EksComponentBuilderFactory {
             case "useDefaultCredentialsProvider": getOrCreateConfiguration((EKS2Component) component).setUseDefaultCredentialsProvider((boolean) value); return true;
             case "useProfileCredentialsProvider": getOrCreateConfiguration((EKS2Component) component).setUseProfileCredentialsProvider((boolean) value); return true;
             case "autowiredEnabled": ((EKS2Component) component).setAutowiredEnabled((boolean) value); return true;
+            case "healthCheckConsumerEnabled": ((EKS2Component) component).setHealthCheckConsumerEnabled((boolean) value); return true;
+            case "healthCheckEnabled": ((EKS2Component) component).setHealthCheckEnabled((boolean) value); return true;
+            case "healthCheckProducerEnabled": ((EKS2Component) component).setHealthCheckProducerEnabled((boolean) value); return true;
             case "accessKey": getOrCreateConfiguration((EKS2Component) component).setAccessKey((java.lang.String) value); return true;
             case "secretKey": getOrCreateConfiguration((EKS2Component) component).setSecretKey((java.lang.String) value); return true;
             default: return false;
diff --git a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2EventbridgeComponentBuilderFactory.java b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2EventbridgeComponentBuilderFactory.java
index b82bafa37f1..83d3fb781b8 100644
--- a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2EventbridgeComponentBuilderFactory.java
+++ b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2EventbridgeComponentBuilderFactory.java
@@ -342,6 +342,56 @@ public interface Aws2EventbridgeComponentBuilderFactory {
             doSetProperty("autowiredEnabled", autowiredEnabled);
             return this;
         }
+        /**
+         * Used for enabling or disabling all consumer based health checks from
+         * this component.
+         * 
+         * The option is a: &lt;code&gt;boolean&lt;/code&gt; type.
+         * 
+         * Default: true
+         * Group: health
+         * 
+         * @param healthCheckConsumerEnabled the value to set
+         * @return the dsl builder
+         */
+        default Aws2EventbridgeComponentBuilder healthCheckConsumerEnabled(
+                boolean healthCheckConsumerEnabled) {
+            doSetProperty("healthCheckConsumerEnabled", healthCheckConsumerEnabled);
+            return this;
+        }
+        /**
+         * Used for enabling or disabling all health checks from this component.
+         * 
+         * The option is a: &lt;code&gt;boolean&lt;/code&gt; type.
+         * 
+         * Default: true
+         * Group: health
+         * 
+         * @param healthCheckEnabled the value to set
+         * @return the dsl builder
+         */
+        default Aws2EventbridgeComponentBuilder healthCheckEnabled(
+                boolean healthCheckEnabled) {
+            doSetProperty("healthCheckEnabled", healthCheckEnabled);
+            return this;
+        }
+        /**
+         * Used for enabling or disabling all producer based health checks from
+         * this component.
+         * 
+         * The option is a: &lt;code&gt;boolean&lt;/code&gt; type.
+         * 
+         * Default: true
+         * Group: health
+         * 
+         * @param healthCheckProducerEnabled the value to set
+         * @return the dsl builder
+         */
+        default Aws2EventbridgeComponentBuilder healthCheckProducerEnabled(
+                boolean healthCheckProducerEnabled) {
+            doSetProperty("healthCheckProducerEnabled", healthCheckProducerEnabled);
+            return this;
+        }
         /**
          * Amazon AWS Access Key.
          * 
@@ -413,6 +463,9 @@ public interface Aws2EventbridgeComponentBuilderFactory {
             case "useDefaultCredentialsProvider": getOrCreateConfiguration((EventbridgeComponent) component).setUseDefaultCredentialsProvider((boolean) value); return true;
             case "useProfileCredentialsProvider": getOrCreateConfiguration((EventbridgeComponent) component).setUseProfileCredentialsProvider((boolean) value); return true;
             case "autowiredEnabled": ((EventbridgeComponent) component).setAutowiredEnabled((boolean) value); return true;
+            case "healthCheckConsumerEnabled": ((EventbridgeComponent) component).setHealthCheckConsumerEnabled((boolean) value); return true;
+            case "healthCheckEnabled": ((EventbridgeComponent) component).setHealthCheckEnabled((boolean) value); return true;
+            case "healthCheckProducerEnabled": ((EventbridgeComponent) component).setHealthCheckProducerEnabled((boolean) value); return true;
             case "accessKey": getOrCreateConfiguration((EventbridgeComponent) component).setAccessKey((java.lang.String) value); return true;
             case "secretKey": getOrCreateConfiguration((EventbridgeComponent) component).setSecretKey((java.lang.String) value); return true;
             default: return false;
diff --git a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2IamComponentBuilderFactory.java b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2IamComponentBuilderFactory.java
index ef3469da02c..e9d0fa6b85d 100644
--- a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2IamComponentBuilderFactory.java
+++ b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2IamComponentBuilderFactory.java
@@ -322,6 +322,56 @@ public interface Aws2IamComponentBuilderFactory {
             doSetProperty("autowiredEnabled", autowiredEnabled);
             return this;
         }
+        /**
+         * Used for enabling or disabling all consumer based health checks from
+         * this component.
+         * 
+         * The option is a: &lt;code&gt;boolean&lt;/code&gt; type.
+         * 
+         * Default: true
+         * Group: health
+         * 
+         * @param healthCheckConsumerEnabled the value to set
+         * @return the dsl builder
+         */
+        default Aws2IamComponentBuilder healthCheckConsumerEnabled(
+                boolean healthCheckConsumerEnabled) {
+            doSetProperty("healthCheckConsumerEnabled", healthCheckConsumerEnabled);
+            return this;
+        }
+        /**
+         * Used for enabling or disabling all health checks from this component.
+         * 
+         * The option is a: &lt;code&gt;boolean&lt;/code&gt; type.
+         * 
+         * Default: true
+         * Group: health
+         * 
+         * @param healthCheckEnabled the value to set
+         * @return the dsl builder
+         */
+        default Aws2IamComponentBuilder healthCheckEnabled(
+                boolean healthCheckEnabled) {
+            doSetProperty("healthCheckEnabled", healthCheckEnabled);
+            return this;
+        }
+        /**
+         * Used for enabling or disabling all producer based health checks from
+         * this component.
+         * 
+         * The option is a: &lt;code&gt;boolean&lt;/code&gt; type.
+         * 
+         * Default: true
+         * Group: health
+         * 
+         * @param healthCheckProducerEnabled the value to set
+         * @return the dsl builder
+         */
+        default Aws2IamComponentBuilder healthCheckProducerEnabled(
+                boolean healthCheckProducerEnabled) {
+            doSetProperty("healthCheckProducerEnabled", healthCheckProducerEnabled);
+            return this;
+        }
         /**
          * Amazon AWS Access Key.
          * 
@@ -390,6 +440,9 @@ public interface Aws2IamComponentBuilderFactory {
             case "useDefaultCredentialsProvider": getOrCreateConfiguration((IAM2Component) component).setUseDefaultCredentialsProvider((boolean) value); return true;
             case "useProfileCredentialsProvider": getOrCreateConfiguration((IAM2Component) component).setUseProfileCredentialsProvider((boolean) value); return true;
             case "autowiredEnabled": ((IAM2Component) component).setAutowiredEnabled((boolean) value); return true;
+            case "healthCheckConsumerEnabled": ((IAM2Component) component).setHealthCheckConsumerEnabled((boolean) value); return true;
+            case "healthCheckEnabled": ((IAM2Component) component).setHealthCheckEnabled((boolean) value); return true;
+            case "healthCheckProducerEnabled": ((IAM2Component) component).setHealthCheckProducerEnabled((boolean) value); return true;
             case "accessKey": getOrCreateConfiguration((IAM2Component) component).setAccessKey((java.lang.String) value); return true;
             case "secretKey": getOrCreateConfiguration((IAM2Component) component).setSecretKey((java.lang.String) value); return true;
             default: return false;
diff --git a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2LambdaComponentBuilderFactory.java b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2LambdaComponentBuilderFactory.java
index 4a451846974..2468c55726d 100644
--- a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2LambdaComponentBuilderFactory.java
+++ b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2LambdaComponentBuilderFactory.java
@@ -278,6 +278,56 @@ public interface Aws2LambdaComponentBuilderFactory {
             doSetProperty("awsLambdaClient", awsLambdaClient);
             return this;
         }
+        /**
+         * Used for enabling or disabling all consumer based health checks from
+         * this component.
+         * 
+         * The option is a: &lt;code&gt;boolean&lt;/code&gt; type.
+         * 
+         * Default: true
+         * Group: health
+         * 
+         * @param healthCheckConsumerEnabled the value to set
+         * @return the dsl builder
+         */
+        default Aws2LambdaComponentBuilder healthCheckConsumerEnabled(
+                boolean healthCheckConsumerEnabled) {
+            doSetProperty("healthCheckConsumerEnabled", healthCheckConsumerEnabled);
+            return this;
+        }
+        /**
+         * Used for enabling or disabling all health checks from this component.
+         * 
+         * The option is a: &lt;code&gt;boolean&lt;/code&gt; type.
+         * 
+         * Default: true
+         * Group: health
+         * 
+         * @param healthCheckEnabled the value to set
+         * @return the dsl builder
+         */
+        default Aws2LambdaComponentBuilder healthCheckEnabled(
+                boolean healthCheckEnabled) {
+            doSetProperty("healthCheckEnabled", healthCheckEnabled);
+            return this;
+        }
+        /**
+         * Used for enabling or disabling all producer based health checks from
+         * this component.
+         * 
+         * The option is a: &lt;code&gt;boolean&lt;/code&gt; type.
+         * 
+         * Default: true
+         * Group: health
+         * 
+         * @param healthCheckProducerEnabled the value to set
+         * @return the dsl builder
+         */
+        default Aws2LambdaComponentBuilder healthCheckProducerEnabled(
+                boolean healthCheckProducerEnabled) {
+            doSetProperty("healthCheckProducerEnabled", healthCheckProducerEnabled);
+            return this;
+        }
         /**
          * To define a proxy host when instantiating the Lambda client.
          * 
@@ -388,6 +438,9 @@ public interface Aws2LambdaComponentBuilderFactory {
             case "useProfileCredentialsProvider": getOrCreateConfiguration((Lambda2Component) component).setUseProfileCredentialsProvider((boolean) value); return true;
             case "autowiredEnabled": ((Lambda2Component) component).setAutowiredEnabled((boolean) value); return true;
             case "awsLambdaClient": getOrCreateConfiguration((Lambda2Component) component).setAwsLambdaClient((software.amazon.awssdk.services.lambda.LambdaClient) value); return true;
+            case "healthCheckConsumerEnabled": ((Lambda2Component) component).setHealthCheckConsumerEnabled((boolean) value); return true;
+            case "healthCheckEnabled": ((Lambda2Component) component).setHealthCheckEnabled((boolean) value); return true;
+            case "healthCheckProducerEnabled": ((Lambda2Component) component).setHealthCheckProducerEnabled((boolean) value); return true;
             case "proxyHost": getOrCreateConfiguration((Lambda2Component) component).setProxyHost((java.lang.String) value); return true;
             case "proxyPort": getOrCreateConfiguration((Lambda2Component) component).setProxyPort((java.lang.Integer) value); return true;
             case "proxyProtocol": getOrCreateConfiguration((Lambda2Component) component).setProxyProtocol((software.amazon.awssdk.core.Protocol) value); return true;
diff --git a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2MqComponentBuilderFactory.java b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2MqComponentBuilderFactory.java
index 0f459f76747..c4621e07012 100644
--- a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2MqComponentBuilderFactory.java
+++ b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2MqComponentBuilderFactory.java
@@ -319,6 +319,56 @@ public interface Aws2MqComponentBuilderFactory {
             doSetProperty("autowiredEnabled", autowiredEnabled);
             return this;
         }
+        /**
+         * Used for enabling or disabling all consumer based health checks from
+         * this component.
+         * 
+         * The option is a: &lt;code&gt;boolean&lt;/code&gt; type.
+         * 
+         * Default: true
+         * Group: health
+         * 
+         * @param healthCheckConsumerEnabled the value to set
+         * @return the dsl builder
+         */
+        default Aws2MqComponentBuilder healthCheckConsumerEnabled(
+                boolean healthCheckConsumerEnabled) {
+            doSetProperty("healthCheckConsumerEnabled", healthCheckConsumerEnabled);
+            return this;
+        }
+        /**
+         * Used for enabling or disabling all health checks from this component.
+         * 
+         * The option is a: &lt;code&gt;boolean&lt;/code&gt; type.
+         * 
+         * Default: true
+         * Group: health
+         * 
+         * @param healthCheckEnabled the value to set
+         * @return the dsl builder
+         */
+        default Aws2MqComponentBuilder healthCheckEnabled(
+                boolean healthCheckEnabled) {
+            doSetProperty("healthCheckEnabled", healthCheckEnabled);
+            return this;
+        }
+        /**
+         * Used for enabling or disabling all producer based health checks from
+         * this component.
+         * 
+         * The option is a: &lt;code&gt;boolean&lt;/code&gt; type.
+         * 
+         * Default: true
+         * Group: health
+         * 
+         * @param healthCheckProducerEnabled the value to set
+         * @return the dsl builder
+         */
+        default Aws2MqComponentBuilder healthCheckProducerEnabled(
+                boolean healthCheckProducerEnabled) {
+            doSetProperty("healthCheckProducerEnabled", healthCheckProducerEnabled);
+            return this;
+        }
         /**
          * Amazon AWS Access Key.
          * 
@@ -387,6 +437,9 @@ public interface Aws2MqComponentBuilderFactory {
             case "useDefaultCredentialsProvider": getOrCreateConfiguration((MQ2Component) component).setUseDefaultCredentialsProvider((boolean) value); return true;
             case "useProfileCredentialsProvider": getOrCreateConfiguration((MQ2Component) component).setUseProfileCredentialsProvider((boolean) value); return true;
             case "autowiredEnabled": ((MQ2Component) component).setAutowiredEnabled((boolean) value); return true;
+            case "healthCheckConsumerEnabled": ((MQ2Component) component).setHealthCheckConsumerEnabled((boolean) value); return true;
+            case "healthCheckEnabled": ((MQ2Component) component).setHealthCheckEnabled((boolean) value); return true;
+            case "healthCheckProducerEnabled": ((MQ2Component) component).setHealthCheckProducerEnabled((boolean) value); return true;
             case "accessKey": getOrCreateConfiguration((MQ2Component) component).setAccessKey((java.lang.String) value); return true;
             case "secretKey": getOrCreateConfiguration((MQ2Component) component).setSecretKey((java.lang.String) value); return true;
             default: return false;
diff --git a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2MskComponentBuilderFactory.java b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2MskComponentBuilderFactory.java
index 2b2fc0d9089..c5c7fc98c6e 100644
--- a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2MskComponentBuilderFactory.java
+++ b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2MskComponentBuilderFactory.java
@@ -319,6 +319,56 @@ public interface Aws2MskComponentBuilderFactory {
             doSetProperty("autowiredEnabled", autowiredEnabled);
             return this;
         }
+        /**
+         * Used for enabling or disabling all consumer based health checks from
+         * this component.
+         * 
+         * The option is a: &lt;code&gt;boolean&lt;/code&gt; type.
+         * 
+         * Default: true
+         * Group: health
+         * 
+         * @param healthCheckConsumerEnabled the value to set
+         * @return the dsl builder
+         */
+        default Aws2MskComponentBuilder healthCheckConsumerEnabled(
+                boolean healthCheckConsumerEnabled) {
+            doSetProperty("healthCheckConsumerEnabled", healthCheckConsumerEnabled);
+            return this;
+        }
+        /**
+         * Used for enabling or disabling all health checks from this component.
+         * 
+         * The option is a: &lt;code&gt;boolean&lt;/code&gt; type.
+         * 
+         * Default: true
+         * Group: health
+         * 
+         * @param healthCheckEnabled the value to set
+         * @return the dsl builder
+         */
+        default Aws2MskComponentBuilder healthCheckEnabled(
+                boolean healthCheckEnabled) {
+            doSetProperty("healthCheckEnabled", healthCheckEnabled);
+            return this;
+        }
+        /**
+         * Used for enabling or disabling all producer based health checks from
+         * this component.
+         * 
+         * The option is a: &lt;code&gt;boolean&lt;/code&gt; type.
+         * 
+         * Default: true
+         * Group: health
+         * 
+         * @param healthCheckProducerEnabled the value to set
+         * @return the dsl builder
+         */
+        default Aws2MskComponentBuilder healthCheckProducerEnabled(
+                boolean healthCheckProducerEnabled) {
+            doSetProperty("healthCheckProducerEnabled", healthCheckProducerEnabled);
+            return this;
+        }
         /**
          * Amazon AWS Access Key.
          * 
@@ -387,6 +437,9 @@ public interface Aws2MskComponentBuilderFactory {
             case "useDefaultCredentialsProvider": getOrCreateConfiguration((MSK2Component) component).setUseDefaultCredentialsProvider((boolean) value); return true;
             case "useProfileCredentialsProvider": getOrCreateConfiguration((MSK2Component) component).setUseProfileCredentialsProvider((boolean) value); return true;
             case "autowiredEnabled": ((MSK2Component) component).setAutowiredEnabled((boolean) value); return true;
+            case "healthCheckConsumerEnabled": ((MSK2Component) component).setHealthCheckConsumerEnabled((boolean) value); return true;
+            case "healthCheckEnabled": ((MSK2Component) component).setHealthCheckEnabled((boolean) value); return true;
+            case "healthCheckProducerEnabled": ((MSK2Component) component).setHealthCheckProducerEnabled((boolean) value); return true;
             case "accessKey": getOrCreateConfiguration((MSK2Component) component).setAccessKey((java.lang.String) value); return true;
             case "secretKey": getOrCreateConfiguration((MSK2Component) component).setSecretKey((java.lang.String) value); return true;
             default: return false;
diff --git a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2SesComponentBuilderFactory.java b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2SesComponentBuilderFactory.java
index e71c70ac0f8..e2e741bd823 100644
--- a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2SesComponentBuilderFactory.java
+++ b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2SesComponentBuilderFactory.java
@@ -395,6 +395,56 @@ public interface Aws2SesComponentBuilderFactory {
             doSetProperty("autowiredEnabled", autowiredEnabled);
             return this;
         }
+        /**
+         * Used for enabling or disabling all consumer based health checks from
+         * this component.
+         * 
+         * The option is a: &lt;code&gt;boolean&lt;/code&gt; type.
+         * 
+         * Default: true
+         * Group: health
+         * 
+         * @param healthCheckConsumerEnabled the value to set
+         * @return the dsl builder
+         */
+        default Aws2SesComponentBuilder healthCheckConsumerEnabled(
+                boolean healthCheckConsumerEnabled) {
+            doSetProperty("healthCheckConsumerEnabled", healthCheckConsumerEnabled);
+            return this;
+        }
+        /**
+         * Used for enabling or disabling all health checks from this component.
+         * 
+         * The option is a: &lt;code&gt;boolean&lt;/code&gt; type.
+         * 
+         * Default: true
+         * Group: health
+         * 
+         * @param healthCheckEnabled the value to set
+         * @return the dsl builder
+         */
+        default Aws2SesComponentBuilder healthCheckEnabled(
+                boolean healthCheckEnabled) {
+            doSetProperty("healthCheckEnabled", healthCheckEnabled);
+            return this;
+        }
+        /**
+         * Used for enabling or disabling all producer based health checks from
+         * this component.
+         * 
+         * The option is a: &lt;code&gt;boolean&lt;/code&gt; type.
+         * 
+         * Default: true
+         * Group: health
+         * 
+         * @param healthCheckProducerEnabled the value to set
+         * @return the dsl builder
+         */
+        default Aws2SesComponentBuilder healthCheckProducerEnabled(
+                boolean healthCheckProducerEnabled) {
+            doSetProperty("healthCheckProducerEnabled", healthCheckProducerEnabled);
+            return this;
+        }
         /**
          * Amazon AWS Access Key.
          * 
@@ -468,6 +518,9 @@ public interface Aws2SesComponentBuilderFactory {
             case "useDefaultCredentialsProvider": getOrCreateConfiguration((Ses2Component) component).setUseDefaultCredentialsProvider((boolean) value); return true;
             case "useProfileCredentialsProvider": getOrCreateConfiguration((Ses2Component) component).setUseProfileCredentialsProvider((boolean) value); return true;
             case "autowiredEnabled": ((Ses2Component) component).setAutowiredEnabled((boolean) value); return true;
+            case "healthCheckConsumerEnabled": ((Ses2Component) component).setHealthCheckConsumerEnabled((boolean) value); return true;
+            case "healthCheckEnabled": ((Ses2Component) component).setHealthCheckEnabled((boolean) value); return true;
+            case "healthCheckProducerEnabled": ((Ses2Component) component).setHealthCheckProducerEnabled((boolean) value); return true;
             case "accessKey": getOrCreateConfiguration((Ses2Component) component).setAccessKey((java.lang.String) value); return true;
             case "secretKey": getOrCreateConfiguration((Ses2Component) component).setSecretKey((java.lang.String) value); return true;
             default: return false;
diff --git a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2SnsComponentBuilderFactory.java b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2SnsComponentBuilderFactory.java
index 3583de73465..83883f74c38 100644
--- a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2SnsComponentBuilderFactory.java
+++ b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2SnsComponentBuilderFactory.java
@@ -452,6 +452,56 @@ public interface Aws2SnsComponentBuilderFactory {
             doSetProperty("autowiredEnabled", autowiredEnabled);
             return this;
         }
+        /**
+         * Used for enabling or disabling all consumer based health checks from
+         * this component.
+         * 
+         * The option is a: &lt;code&gt;boolean&lt;/code&gt; type.
+         * 
+         * Default: true
+         * Group: health
+         * 
+         * @param healthCheckConsumerEnabled the value to set
+         * @return the dsl builder
+         */
+        default Aws2SnsComponentBuilder healthCheckConsumerEnabled(
+                boolean healthCheckConsumerEnabled) {
+            doSetProperty("healthCheckConsumerEnabled", healthCheckConsumerEnabled);
+            return this;
+        }
+        /**
+         * Used for enabling or disabling all health checks from this component.
+         * 
+         * The option is a: &lt;code&gt;boolean&lt;/code&gt; type.
+         * 
+         * Default: true
+         * Group: health
+         * 
+         * @param healthCheckEnabled the value to set
+         * @return the dsl builder
+         */
+        default Aws2SnsComponentBuilder healthCheckEnabled(
+                boolean healthCheckEnabled) {
+            doSetProperty("healthCheckEnabled", healthCheckEnabled);
+            return this;
+        }
+        /**
+         * Used for enabling or disabling all producer based health checks from
+         * this component.
+         * 
+         * The option is a: &lt;code&gt;boolean&lt;/code&gt; type.
+         * 
+         * Default: true
+         * Group: health
+         * 
+         * @param healthCheckProducerEnabled the value to set
+         * @return the dsl builder
+         */
+        default Aws2SnsComponentBuilder healthCheckProducerEnabled(
+                boolean healthCheckProducerEnabled) {
+            doSetProperty("healthCheckProducerEnabled", healthCheckProducerEnabled);
+            return this;
+        }
         /**
          * Amazon AWS Access Key.
          * 
@@ -528,6 +578,9 @@ public interface Aws2SnsComponentBuilderFactory {
             case "useDefaultCredentialsProvider": getOrCreateConfiguration((Sns2Component) component).setUseDefaultCredentialsProvider((boolean) value); return true;
             case "useProfileCredentialsProvider": getOrCreateConfiguration((Sns2Component) component).setUseProfileCredentialsProvider((boolean) value); return true;
             case "autowiredEnabled": ((Sns2Component) component).setAutowiredEnabled((boolean) value); return true;
+            case "healthCheckConsumerEnabled": ((Sns2Component) component).setHealthCheckConsumerEnabled((boolean) value); return true;
+            case "healthCheckEnabled": ((Sns2Component) component).setHealthCheckEnabled((boolean) value); return true;
+            case "healthCheckProducerEnabled": ((Sns2Component) component).setHealthCheckProducerEnabled((boolean) value); return true;
             case "accessKey": getOrCreateConfiguration((Sns2Component) component).setAccessKey((java.lang.String) value); return true;
             case "secretKey": getOrCreateConfiguration((Sns2Component) component).setSecretKey((java.lang.String) value); return true;
             default: return false;
diff --git a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2TranslateComponentBuilderFactory.java b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2TranslateComponentBuilderFactory.java
index 02a813c126c..eed94c392cd 100644
--- a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2TranslateComponentBuilderFactory.java
+++ b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2TranslateComponentBuilderFactory.java
@@ -370,6 +370,56 @@ public interface Aws2TranslateComponentBuilderFactory {
             doSetProperty("autowiredEnabled", autowiredEnabled);
             return this;
         }
+        /**
+         * Used for enabling or disabling all consumer based health checks from
+         * this component.
+         * 
+         * The option is a: &lt;code&gt;boolean&lt;/code&gt; type.
+         * 
+         * Default: true
+         * Group: health
+         * 
+         * @param healthCheckConsumerEnabled the value to set
+         * @return the dsl builder
+         */
+        default Aws2TranslateComponentBuilder healthCheckConsumerEnabled(
+                boolean healthCheckConsumerEnabled) {
+            doSetProperty("healthCheckConsumerEnabled", healthCheckConsumerEnabled);
+            return this;
+        }
+        /**
+         * Used for enabling or disabling all health checks from this component.
+         * 
+         * The option is a: &lt;code&gt;boolean&lt;/code&gt; type.
+         * 
+         * Default: true
+         * Group: health
+         * 
+         * @param healthCheckEnabled the value to set
+         * @return the dsl builder
+         */
+        default Aws2TranslateComponentBuilder healthCheckEnabled(
+                boolean healthCheckEnabled) {
+            doSetProperty("healthCheckEnabled", healthCheckEnabled);
+            return this;
+        }
+        /**
+         * Used for enabling or disabling all producer based health checks from
+         * this component.
+         * 
+         * The option is a: &lt;code&gt;boolean&lt;/code&gt; type.
+         * 
+         * Default: true
+         * Group: health
+         * 
+         * @param healthCheckProducerEnabled the value to set
+         * @return the dsl builder
+         */
+        default Aws2TranslateComponentBuilder healthCheckProducerEnabled(
+                boolean healthCheckProducerEnabled) {
+            doSetProperty("healthCheckProducerEnabled", healthCheckProducerEnabled);
+            return this;
+        }
         /**
          * Amazon AWS Access Key.
          * 
@@ -443,6 +493,9 @@ public interface Aws2TranslateComponentBuilderFactory {
             case "useDefaultCredentialsProvider": getOrCreateConfiguration((Translate2Component) component).setUseDefaultCredentialsProvider((boolean) value); return true;
             case "useProfileCredentialsProvider": getOrCreateConfiguration((Translate2Component) component).setUseProfileCredentialsProvider((boolean) value); return true;
             case "autowiredEnabled": ((Translate2Component) component).setAutowiredEnabled((boolean) value); return true;
+            case "healthCheckConsumerEnabled": ((Translate2Component) component).setHealthCheckConsumerEnabled((boolean) value); return true;
+            case "healthCheckEnabled": ((Translate2Component) component).setHealthCheckEnabled((boolean) value); return true;
+            case "healthCheckProducerEnabled": ((Translate2Component) component).setHealthCheckProducerEnabled((boolean) value); return true;
             case "accessKey": getOrCreateConfiguration((Translate2Component) component).setAccessKey((java.lang.String) value); return true;
             case "secretKey": getOrCreateConfiguration((Translate2Component) component).setSecretKey((java.lang.String) value); return true;
             default: return false;


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

Posted by da...@apache.org.
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 ae2d5c82324955205cf258ca8a8e54f034e6de5d
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri Jul 28 10:08:57 2023 +0200

    CAMEL-19645: camel-aws - producer health check
---
 .../aws2/ses/Ses2ComponentConfigurer.java          | 18 +++++++++++++
 .../apache/camel/component/aws2/ses/aws2-ses.json  |  7 +++--
 .../camel/component/aws2/ses/Ses2Component.java    |  5 ++--
 .../camel/component/aws2/ses/Ses2Endpoint.java     | 25 ++++-------------
 .../camel/component/aws2/ses/Ses2Producer.java     | 31 ++++++++++++++++++++++
 ...althCheck.java => Ses2ProducerHealthCheck.java} |  7 +++--
 ...> Ses2ProducerHealthCheckProfileCredsTest.java} | 13 ++-------
 ...=> Ses2ProducerHealthCheckStaticCredsTest.java} | 13 ++-------
 8 files changed, 69 insertions(+), 50 deletions(-)

diff --git a/components/camel-aws/camel-aws2-ses/src/generated/java/org/apache/camel/component/aws2/ses/Ses2ComponentConfigurer.java b/components/camel-aws/camel-aws2-ses/src/generated/java/org/apache/camel/component/aws2/ses/Ses2ComponentConfigurer.java
index 8932a4cc8fd..ea747b17fe1 100644
--- a/components/camel-aws/camel-aws2-ses/src/generated/java/org/apache/camel/component/aws2/ses/Ses2ComponentConfigurer.java
+++ b/components/camel-aws/camel-aws2-ses/src/generated/java/org/apache/camel/component/aws2/ses/Ses2ComponentConfigurer.java
@@ -39,6 +39,12 @@ public class Ses2ComponentConfigurer extends PropertyConfigurerSupport implement
         case "configuration": target.setConfiguration(property(camelContext, org.apache.camel.component.aws2.ses.Ses2Configuration.class, value)); return true;
         case "configurationset":
         case "configurationSet": getOrCreateConfiguration(target).setConfigurationSet(property(camelContext, java.lang.String.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 "overrideendpoint":
@@ -91,6 +97,12 @@ public class Ses2ComponentConfigurer extends PropertyConfigurerSupport implement
         case "configuration": return org.apache.camel.component.aws2.ses.Ses2Configuration.class;
         case "configurationset":
         case "configurationSet": return java.lang.String.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 "overrideendpoint":
@@ -139,6 +151,12 @@ public class Ses2ComponentConfigurer extends PropertyConfigurerSupport implement
         case "configuration": return target.getConfiguration();
         case "configurationset":
         case "configurationSet": return getOrCreateConfiguration(target).getConfigurationSet();
+        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 "overrideendpoint":
diff --git a/components/camel-aws/camel-aws2-ses/src/generated/resources/org/apache/camel/component/aws2/ses/aws2-ses.json b/components/camel-aws/camel-aws2-ses/src/generated/resources/org/apache/camel/component/aws2/ses/aws2-ses.json
index 5cdca1ffe7f..cbc64a45e2c 100644
--- a/components/camel-aws/camel-aws2-ses/src/generated/resources/org/apache/camel/component/aws2/ses/aws2-ses.json
+++ b/components/camel-aws/camel-aws2-ses/src/generated/resources/org/apache/camel/component/aws2/ses/aws2-ses.json
@@ -43,8 +43,11 @@
     "useDefaultCredentialsProvider": { "index": 18, "kind": "property", "displayName": "Use Default 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.ses.Ses2Configuration", "configurationField": "configuration", "description": "Set whether the Ses client should expect to load credential [...]
     "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.ses.Ses2Configuration", "configurationField": "configuration", "description": "Set whether the SES client should expect to load credential [...]
     "autowiredEnabled": { "index": 20, "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": 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.ses.Ses2Configuration", "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.ses.Ses2Configuration", "configurationField": "configuration", "description": "Amazon AWS Secret Key" }
+    "healthCheckConsumerEnabled": { "index": 21, "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": 22, "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": 23, "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": 24, "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.ses.Ses2Configuration", "configurationField": "configuration", "description": "Amazon AWS Access Key" },
+    "secretKey": { "index": 25, "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.ses.Ses2Configuration", "configurationField": "configuration", "description": "Amazon AWS Secret Key" }
   },
   "headers": {
     "CamelAwsSesFrom": { "index": 0, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The sender's email address.", "constantName": "org.apache.camel.component.aws2.ses.Ses2Constants#FROM" },
diff --git a/components/camel-aws/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Component.java b/components/camel-aws/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Component.java
index a00d06544b2..1b0cd4211d9 100644
--- a/components/camel-aws/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Component.java
+++ b/components/camel-aws/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Component.java
@@ -22,13 +22,14 @@ 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 SES SDK v2.
  */
 @Component("aws2-ses")
-public class Ses2Component extends DefaultComponent {
+public class Ses2Component extends HealthCheckComponent {
+
     @Metadata
     private Ses2Configuration configuration = new Ses2Configuration();
 
diff --git a/components/camel-aws/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Endpoint.java b/components/camel-aws/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Endpoint.java
index ce97a04bebf..e98049ca874 100644
--- a/components/camel-aws/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Endpoint.java
+++ b/components/camel-aws/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Endpoint.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.ses.client.Ses2ClientFactory;
-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;
@@ -37,9 +35,6 @@ import software.amazon.awssdk.services.ses.SesClient;
              producerOnly = true, category = { Category.CLOUD, Category.MAIL }, headersClass = Ses2Constants.class)
 public class Ses2Endpoint extends DefaultEndpoint {
 
-    private ComponentsHealthCheckRepository healthCheckRepository;
-    private Ses2HealthCheck clientHealthCheck;
-
     private SesClient sesClient;
 
     @UriParam
@@ -50,21 +45,17 @@ public class Ses2Endpoint extends DefaultEndpoint {
         this.configuration = configuration;
     }
 
+    @Override
+    public Ses2Component getComponent() {
+        return (Ses2Component) super.getComponent();
+    }
+
     @Override
     public void doStart() throws Exception {
         super.doStart();
         sesClient = configuration.getAmazonSESClient() != null
                 ? configuration.getAmazonSESClient()
                 : Ses2ClientFactory.getSesClient(configuration).getSesClient();
-
-        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 Ses2HealthCheck(this, getId());
-            // healthCheckRepository.addHealthCheck(clientHealthCheck);
-        }
     }
 
     @Override
@@ -74,12 +65,6 @@ public class Ses2Endpoint extends DefaultEndpoint {
                 sesClient.close();
             }
         }
-
-        if (healthCheckRepository != null && clientHealthCheck != null) {
-            healthCheckRepository.removeHealthCheck(clientHealthCheck);
-            clientHealthCheck = null;
-        }
-
         super.doStop();
     }
 
diff --git a/components/camel-aws/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Producer.java b/components/camel-aws/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Producer.java
index fb24f157524..e68b83ec895 100644
--- a/components/camel-aws/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Producer.java
+++ b/components/camel-aws/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Producer.java
@@ -27,6 +27,9 @@ import java.util.stream.Stream;
 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;
 import org.apache.camel.util.ObjectHelper;
 import org.apache.camel.util.URISupport;
@@ -50,6 +53,8 @@ public class Ses2Producer extends DefaultProducer {
     private static final Logger LOG = LoggerFactory.getLogger(Ses2Producer.class);
 
     private transient String sesProducerToString;
+    private HealthCheck producerHealthCheck;
+    private WritableHealthCheckRepository healthCheckRepository;
 
     public Ses2Producer(Endpoint endpoint) {
         super(endpoint);
@@ -240,4 +245,30 @@ public class Ses2Producer extends DefaultProducer {
     public static Message getMessageForResponse(final Exchange exchange) {
         return exchange.getMessage();
     }
+
+    @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 Ses2ProducerHealthCheck(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-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2HealthCheck.java b/components/camel-aws/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2ProducerHealthCheck.java
similarity index 91%
rename from components/camel-aws/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2HealthCheck.java
rename to components/camel-aws/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2ProducerHealthCheck.java
index b04ccd928ac..f9c632f02fa 100644
--- a/components/camel-aws/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2HealthCheck.java
+++ b/components/camel-aws/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2ProducerHealthCheck.java
@@ -24,18 +24,17 @@ import software.amazon.awssdk.awscore.exception.AwsServiceException;
 import software.amazon.awssdk.regions.Region;
 import software.amazon.awssdk.services.ses.SesClient;
 
-public class Ses2HealthCheck extends AbstractHealthCheck {
+public class Ses2ProducerHealthCheck extends AbstractHealthCheck {
 
     private final Ses2Endpoint ses2Endpoint;
 
-    public Ses2HealthCheck(Ses2Endpoint ses2Endpoint, String clientId) {
-        super("camel", "aws2-ses-client-" + clientId);
+    public Ses2ProducerHealthCheck(Ses2Endpoint ses2Endpoint, String clientId) {
+        super("camel", "aws2-ses-producer-" + clientId);
         this.ses2Endpoint = ses2Endpoint;
     }
 
     @Override
     protected void doCall(HealthCheckResultBuilder builder, Map<String, Object> options) {
-
         Ses2Configuration configuration = ses2Endpoint.getConfiguration();
         try {
             if (!SesClient.serviceMetadata().regions().contains(Region.of(configuration.getRegion()))) {
diff --git a/components/camel-aws/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/Ses2HealthCheckProfileCredsTest.java b/components/camel-aws/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/Ses2ProducerHealthCheckProfileCredsTest.java
similarity index 87%
rename from components/camel-aws/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/Ses2HealthCheckProfileCredsTest.java
rename to components/camel-aws/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/Ses2ProducerHealthCheckProfileCredsTest.java
index 35ae715957f..c8dcd536052 100644
--- a/components/camel-aws/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/Ses2HealthCheckProfileCredsTest.java
+++ b/components/camel-aws/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/Ses2ProducerHealthCheckProfileCredsTest.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 Ses2HealthCheckProfileCredsTest extends CamelTestSupport {
-
-    private static final Logger LOG = LoggerFactory.getLogger(Ses2HealthCheckProfileCredsTest.class);
+public class Ses2ProducerHealthCheckProfileCredsTest extends CamelTestSupport {
 
     CamelContext context;
 
@@ -73,9 +68,7 @@ public class Ses2HealthCheckProfileCredsTest 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);
         boolean up = res.stream().allMatch(r -> r.getState().equals(HealthCheck.State.UP));
         Assertions.assertTrue(up, "liveness check");
@@ -85,9 +78,7 @@ public class Ses2HealthCheckProfileCredsTest extends CamelTestSupport {
             Collection<HealthCheck.Result> res2 = HealthCheckHelper.invokeReadiness(context);
             boolean down = res2.stream().allMatch(r -> r.getState().equals(HealthCheck.State.DOWN));
             boolean containsAws2AthenaHealthCheck = res2.stream()
-                    .filter(result -> result.getCheck().getId().startsWith("aws2-ses-client"))
-                    .findAny()
-                    .isPresent();
+                    .anyMatch(result -> result.getCheck().getId().startsWith("aws2-ses-producer"));
             boolean hasRegionMessage = res2.stream()
                     .anyMatch(r -> r.getMessage().stream().anyMatch(msg -> msg.contains("region")));
             Assertions.assertTrue(down, "liveness check");
diff --git a/components/camel-aws/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/Ses2HealthCheckStaticCredsTest.java b/components/camel-aws/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/Ses2ProducerHealthCheckStaticCredsTest.java
similarity index 87%
rename from components/camel-aws/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/Ses2HealthCheckStaticCredsTest.java
rename to components/camel-aws/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/Ses2ProducerHealthCheckStaticCredsTest.java
index f38913f7af4..25dee40304b 100644
--- a/components/camel-aws/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/Ses2HealthCheckStaticCredsTest.java
+++ b/components/camel-aws/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/Ses2ProducerHealthCheckStaticCredsTest.java
@@ -27,16 +27,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 Ses2HealthCheckStaticCredsTest extends CamelTestSupport {
-
-    private static final Logger LOG = LoggerFactory.getLogger(Ses2HealthCheckStaticCredsTest.class);
+public class Ses2ProducerHealthCheckStaticCredsTest extends CamelTestSupport {
 
     CamelContext context;
 
@@ -72,9 +67,7 @@ public class Ses2HealthCheckStaticCredsTest 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);
         boolean up = res.stream().allMatch(r -> r.getState().equals(HealthCheck.State.UP));
         Assertions.assertTrue(up, "liveness check");
@@ -84,9 +77,7 @@ public class Ses2HealthCheckStaticCredsTest extends CamelTestSupport {
             Collection<HealthCheck.Result> res2 = HealthCheckHelper.invokeReadiness(context);
             boolean down = res2.stream().allMatch(r -> r.getState().equals(HealthCheck.State.DOWN));
             boolean containsAws2AthenaHealthCheck = res2.stream()
-                    .filter(result -> result.getCheck().getId().startsWith("aws2-ses-client"))
-                    .findAny()
-                    .isPresent();
+                    .anyMatch(result -> result.getCheck().getId().startsWith("aws2-ses-producer"));
             boolean hasRegionMessage = res2.stream()
                     .anyMatch(r -> r.getMessage().stream().anyMatch(msg -> msg.contains("region")));
             Assertions.assertTrue(down, "liveness check");


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

Posted by da...@apache.org.
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 5628a80f361f85287f7190eac51b8752dea3fa57
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri Jul 28 10:13:59 2023 +0200

    CAMEL-19645: camel-aws - producer health check
---
 .../translate/Translate2ComponentConfigurer.java   | 18 +++++++++++++
 .../component/aws2/translate/aws2-translate.json   |  7 +++--
 .../aws2/translate/Translate2Component.java        |  5 ++--
 .../aws2/translate/Translate2Endpoint.java         | 24 ++++-------------
 .../aws2/translate/Translate2Producer.java         | 31 ++++++++++++++++++++++
 ...eck.java => Translate2ProducerHealthCheck.java} |  6 ++---
 ...slate2ProducerHealthCheckProfileCredsTest.java} | 13 ++-------
 ...nslate2ProducerHealthCheckStaticCredsTest.java} | 13 ++-------
 8 files changed, 69 insertions(+), 48 deletions(-)

diff --git a/components/camel-aws/camel-aws2-translate/src/generated/java/org/apache/camel/component/aws2/translate/Translate2ComponentConfigurer.java b/components/camel-aws/camel-aws2-translate/src/generated/java/org/apache/camel/component/aws2/translate/Translate2ComponentConfigurer.java
index 79e0476b902..f37195a8d8a 100644
--- a/components/camel-aws/camel-aws2-translate/src/generated/java/org/apache/camel/component/aws2/translate/Translate2ComponentConfigurer.java
+++ b/components/camel-aws/camel-aws2-translate/src/generated/java/org/apache/camel/component/aws2/translate/Translate2ComponentConfigurer.java
@@ -35,6 +35,12 @@ public class Translate2ComponentConfigurer extends PropertyConfigurerSupport imp
         case "autowiredenabled":
         case "autowiredEnabled": target.setAutowiredEnabled(property(camelContext, boolean.class, value)); return true;
         case "configuration": target.setConfiguration(property(camelContext, org.apache.camel.component.aws2.translate.Translate2Configuration.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 "operation": getOrCreateConfiguration(target).setOperation(property(camelContext, org.apache.camel.component.aws2.translate.Translate2Operations.class, value)); return true;
@@ -86,6 +92,12 @@ public class Translate2ComponentConfigurer extends PropertyConfigurerSupport imp
         case "autowiredenabled":
         case "autowiredEnabled": return boolean.class;
         case "configuration": return org.apache.camel.component.aws2.translate.Translate2Configuration.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 "operation": return org.apache.camel.component.aws2.translate.Translate2Operations.class;
@@ -133,6 +145,12 @@ public class Translate2ComponentConfigurer extends PropertyConfigurerSupport imp
         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 "operation": return getOrCreateConfiguration(target).getOperation();
diff --git a/components/camel-aws/camel-aws2-translate/src/generated/resources/org/apache/camel/component/aws2/translate/aws2-translate.json b/components/camel-aws/camel-aws2-translate/src/generated/resources/org/apache/camel/component/aws2/translate/aws2-translate.json
index 4603ae75b0f..807946ffe31 100644
--- a/components/camel-aws/camel-aws2-translate/src/generated/resources/org/apache/camel/component/aws2/translate/aws2-translate.json
+++ b/components/camel-aws/camel-aws2-translate/src/generated/resources/org/apache/camel/component/aws2/translate/aws2-translate.json
@@ -41,8 +41,11 @@
     "useDefaultCredentialsProvider": { "index": 16, "kind": "property", "displayName": "Use Default 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.translate.Translate2Configuration", "configurationField": "configuration", "description": "Set whether the Translate client should expect  [...]
     "useProfileCredentialsProvider": { "index": 17, "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.translate.Translate2Configuration", "configurationField": "configuration", "description": "Set whether the Translate client should expect  [...]
     "autowiredEnabled": { "index": 18, "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": 19, "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.translate.Translate2Configuration", "configurationField": "configuration", "description": "Amazon AWS Access Key" },
-    "secretKey": { "index": 20, "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.translate.Translate2Configuration", "configurationField": "configuration", "description": "Amazon AWS Secret Key" }
+    "healthCheckConsumerEnabled": { "index": 19, "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": 20, "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": 21, "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": 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.translate.Translate2Configuration", "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.translate.Translate2Configuration", "configurationField": "configuration", "description": "Amazon AWS Secret Key" }
   },
   "headers": {
     "CamelAwsTranslateSourceLanguage": { "index": 0, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The text source language", "constantName": "org.apache.camel.component.aws2.translate.Translate2Constants#SOURCE_LANGUAGE" },
diff --git a/components/camel-aws/camel-aws2-translate/src/main/java/org/apache/camel/component/aws2/translate/Translate2Component.java b/components/camel-aws/camel-aws2-translate/src/main/java/org/apache/camel/component/aws2/translate/Translate2Component.java
index 38ef1b5e43b..dfd0cba0f87 100644
--- a/components/camel-aws/camel-aws2-translate/src/main/java/org/apache/camel/component/aws2/translate/Translate2Component.java
+++ b/components/camel-aws/camel-aws2-translate/src/main/java/org/apache/camel/component/aws2/translate/Translate2Component.java
@@ -22,13 +22,14 @@ 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 Translate SDK v2.
  */
 @Component("aws2-translate")
-public class Translate2Component extends DefaultComponent {
+public class Translate2Component extends HealthCheckComponent {
+
     @Metadata
     private Translate2Configuration configuration = new Translate2Configuration();
 
diff --git a/components/camel-aws/camel-aws2-translate/src/main/java/org/apache/camel/component/aws2/translate/Translate2Endpoint.java b/components/camel-aws/camel-aws2-translate/src/main/java/org/apache/camel/component/aws2/translate/Translate2Endpoint.java
index 1c0ba85fce8..2c8e430ca84 100644
--- a/components/camel-aws/camel-aws2-translate/src/main/java/org/apache/camel/component/aws2/translate/Translate2Endpoint.java
+++ b/components/camel-aws/camel-aws2-translate/src/main/java/org/apache/camel/component/aws2/translate/Translate2Endpoint.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.translate.client.Translate2ClientFactory;
-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.ScheduledPollEndpoint;
@@ -39,9 +37,6 @@ public class Translate2Endpoint extends ScheduledPollEndpoint {
 
     private TranslateClient translateClient;
 
-    private ComponentsHealthCheckRepository healthCheckRepository;
-    private Translate2ClientHealthCheck clientHealthCheck;
-
     @UriParam
     private Translate2Configuration configuration;
 
@@ -60,6 +55,11 @@ public class Translate2Endpoint extends ScheduledPollEndpoint {
         return new Translate2Producer(this);
     }
 
+    @Override
+    public Translate2Component getComponent() {
+        return (Translate2Component) super.getComponent();
+    }
+
     @Override
     public void doStart() throws Exception {
         super.doStart();
@@ -68,24 +68,10 @@ public class Translate2Endpoint extends ScheduledPollEndpoint {
                 = configuration.getTranslateClient() != null
                         ? configuration.getTranslateClient()
                         : Translate2ClientFactory.getTranslateClient(configuration).getTranslateClient();
-
-        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 Translate2ClientHealthCheck(this, getId());
-            // healthCheckRepository.addHealthCheck(clientHealthCheck);
-        }
     }
 
     @Override
     public void doStop() throws Exception {
-        if (healthCheckRepository != null && clientHealthCheck != null) {
-            healthCheckRepository.removeHealthCheck(clientHealthCheck);
-            clientHealthCheck = null;
-        }
-
         if (ObjectHelper.isEmpty(configuration.getTranslateClient())) {
             if (translateClient != null) {
                 translateClient.close();
diff --git a/components/camel-aws/camel-aws2-translate/src/main/java/org/apache/camel/component/aws2/translate/Translate2Producer.java b/components/camel-aws/camel-aws2-translate/src/main/java/org/apache/camel/component/aws2/translate/Translate2Producer.java
index ef6961ed6c0..7edeb156ed2 100644
--- a/components/camel-aws/camel-aws2-translate/src/main/java/org/apache/camel/component/aws2/translate/Translate2Producer.java
+++ b/components/camel-aws/camel-aws2-translate/src/main/java/org/apache/camel/component/aws2/translate/Translate2Producer.java
@@ -22,6 +22,9 @@ import org.apache.camel.Endpoint;
 import org.apache.camel.Exchange;
 import org.apache.camel.InvalidPayloadException;
 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;
 import org.apache.camel.util.ObjectHelper;
 import org.apache.camel.util.URISupport;
@@ -41,6 +44,8 @@ public class Translate2Producer extends DefaultProducer {
 
     private static final Logger LOG = LoggerFactory.getLogger(Translate2Producer.class);
     private transient String translateProducerToString;
+    private HealthCheck producerHealthCheck;
+    private WritableHealthCheckRepository healthCheckRepository;
 
     public Translate2Producer(Endpoint endpoint) {
         super(endpoint);
@@ -149,4 +154,30 @@ public class Translate2Producer extends DefaultProducer {
     public static Message getMessageForResponse(final Exchange exchange) {
         return exchange.getMessage();
     }
+
+    @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 Translate2ProducerHealthCheck(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-translate/src/main/java/org/apache/camel/component/aws2/translate/Translate2ClientHealthCheck.java b/components/camel-aws/camel-aws2-translate/src/main/java/org/apache/camel/component/aws2/translate/Translate2ProducerHealthCheck.java
similarity index 92%
rename from components/camel-aws/camel-aws2-translate/src/main/java/org/apache/camel/component/aws2/translate/Translate2ClientHealthCheck.java
rename to components/camel-aws/camel-aws2-translate/src/main/java/org/apache/camel/component/aws2/translate/Translate2ProducerHealthCheck.java
index e14df57ccac..52a9bc6bd7b 100644
--- a/components/camel-aws/camel-aws2-translate/src/main/java/org/apache/camel/component/aws2/translate/Translate2ClientHealthCheck.java
+++ b/components/camel-aws/camel-aws2-translate/src/main/java/org/apache/camel/component/aws2/translate/Translate2ProducerHealthCheck.java
@@ -27,12 +27,12 @@ import software.amazon.awssdk.regions.Region;
 import software.amazon.awssdk.services.translate.TranslateClient;
 import software.amazon.awssdk.services.translate.model.ListLanguagesRequest;
 
-public class Translate2ClientHealthCheck extends AbstractHealthCheck {
+public class Translate2ProducerHealthCheck extends AbstractHealthCheck {
 
     private final Translate2Endpoint translate2Endpoint;
 
-    public Translate2ClientHealthCheck(Translate2Endpoint translate2Endpoint, String clientId) {
-        super("camel", "aws2-translate-client-" + clientId);
+    public Translate2ProducerHealthCheck(Translate2Endpoint translate2Endpoint, String clientId) {
+        super("camel", "aws2-translate-producer-" + clientId);
         this.translate2Endpoint = translate2Endpoint;
     }
 
diff --git a/components/camel-aws/camel-aws2-translate/src/test/java/org/apache/camel/component/aws2/translate/Translate2ClientHealthCheckProfileCredsTest.java b/components/camel-aws/camel-aws2-translate/src/test/java/org/apache/camel/component/aws2/translate/Translate2ProducerHealthCheckProfileCredsTest.java
similarity index 86%
rename from components/camel-aws/camel-aws2-translate/src/test/java/org/apache/camel/component/aws2/translate/Translate2ClientHealthCheckProfileCredsTest.java
rename to components/camel-aws/camel-aws2-translate/src/test/java/org/apache/camel/component/aws2/translate/Translate2ProducerHealthCheckProfileCredsTest.java
index 3d411b8ed20..4a31d642f5d 100644
--- a/components/camel-aws/camel-aws2-translate/src/test/java/org/apache/camel/component/aws2/translate/Translate2ClientHealthCheckProfileCredsTest.java
+++ b/components/camel-aws/camel-aws2-translate/src/test/java/org/apache/camel/component/aws2/translate/Translate2ProducerHealthCheckProfileCredsTest.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 Translate2ClientHealthCheckProfileCredsTest extends CamelTestSupport {
-
-    private static final Logger LOG = LoggerFactory.getLogger(Translate2ClientHealthCheckProfileCredsTest.class);
+public class Translate2ProducerHealthCheckProfileCredsTest extends CamelTestSupport {
 
     CamelContext context;
 
@@ -73,9 +68,7 @@ public class Translate2ClientHealthCheckProfileCredsTest extends CamelTestSuppor
     }
 
     @Test
-    @Disabled("Do not register the Producer Health Check until we solve CAMEL-18992")
     public void testConnectivity() {
-
         Collection<HealthCheck.Result> res = HealthCheckHelper.invokeLiveness(context);
         boolean up = res.stream().allMatch(r -> r.getState().equals(HealthCheck.State.UP));
         Assertions.assertTrue(up, "liveness check");
@@ -85,9 +78,7 @@ public class Translate2ClientHealthCheckProfileCredsTest extends CamelTestSuppor
             Collection<HealthCheck.Result> res2 = HealthCheckHelper.invokeReadiness(context);
             boolean down = res2.stream().allMatch(r -> r.getState().equals(HealthCheck.State.DOWN));
             boolean containsAwsTranslateHealthCheck = res2.stream()
-                    .filter(result -> result.getCheck().getId().startsWith("aws2-translate-client"))
-                    .findAny()
-                    .isPresent();
+                    .anyMatch(result -> result.getCheck().getId().startsWith("aws2-translate-producer"));
             boolean hasRegionMessage = res2.stream()
                     .anyMatch(r -> r.getMessage().stream().anyMatch(msg -> msg.contains("region")));
             Assertions.assertTrue(down, "liveness check");
diff --git a/components/camel-aws/camel-aws2-translate/src/test/java/org/apache/camel/component/aws2/translate/Translate2ClientHealthCheckStaticCredsTest.java b/components/camel-aws/camel-aws2-translate/src/test/java/org/apache/camel/component/aws2/translate/Translate2ProducerHealthCheckStaticCredsTest.java
similarity index 86%
rename from components/camel-aws/camel-aws2-translate/src/test/java/org/apache/camel/component/aws2/translate/Translate2ClientHealthCheckStaticCredsTest.java
rename to components/camel-aws/camel-aws2-translate/src/test/java/org/apache/camel/component/aws2/translate/Translate2ProducerHealthCheckStaticCredsTest.java
index 1598abc22db..6fda42cc593 100644
--- a/components/camel-aws/camel-aws2-translate/src/test/java/org/apache/camel/component/aws2/translate/Translate2ClientHealthCheckStaticCredsTest.java
+++ b/components/camel-aws/camel-aws2-translate/src/test/java/org/apache/camel/component/aws2/translate/Translate2ProducerHealthCheckStaticCredsTest.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 Translate2ClientHealthCheckStaticCredsTest extends CamelTestSupport {
-
-    private static final Logger LOG = LoggerFactory.getLogger(Translate2ClientHealthCheckStaticCredsTest.class);
+public class Translate2ProducerHealthCheckStaticCredsTest extends CamelTestSupport {
 
     CamelContext context;
 
@@ -73,9 +68,7 @@ public class Translate2ClientHealthCheckStaticCredsTest 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);
         boolean up = res.stream().allMatch(r -> r.getState().equals(HealthCheck.State.UP));
         Assertions.assertTrue(up, "liveness check");
@@ -85,9 +78,7 @@ public class Translate2ClientHealthCheckStaticCredsTest extends CamelTestSupport
             Collection<HealthCheck.Result> res2 = HealthCheckHelper.invokeReadiness(context);
             boolean down = res2.stream().allMatch(r -> r.getState().equals(HealthCheck.State.DOWN));
             boolean containsAwsTranslateHealthCheck = res2.stream()
-                    .filter(result -> result.getCheck().getId().startsWith("aws2-translate-client"))
-                    .findAny()
-                    .isPresent();
+                    .anyMatch(result -> result.getCheck().getId().startsWith("aws2-translate-producer"));
             boolean hasRegionMessage = res2.stream()
                     .anyMatch(r -> r.getMessage().stream().anyMatch(msg -> msg.contains("region")));
             Assertions.assertTrue(down, "liveness check");


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

Posted by da...@apache.org.
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 8284ce4aae976f940fc00241e6be213b21d9b39c
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri Jul 28 09:33:01 2023 +0200

    CAMEL-19645: camel-aws - producer health check
---
 .../aws2/ec2/AWS2EC2ComponentConfigurer.java       | 18 ++++++++++++++
 .../apache/camel/component/aws2/ec2/aws2-ec2.json  |  5 +++-
 .../camel/component/aws2/ec2/AWS2EC2Component.java |  5 ++--
 .../camel/component/aws2/ec2/AWS2EC2Endpoint.java  | 22 ++++------------
 .../camel/component/aws2/ec2/AWS2EC2Producer.java  | 29 ++++++++++++++++++++++
 ...hCheck.java => AWS2EC2ProducerHealthCheck.java} |  6 ++---
 ...WS2EC2ProducerHealthCheckProfileCredsTest.java} | 10 ++------
 ...AWS2EC2ProducerHealthCheckStaticCredsTest.java} | 10 ++------
 8 files changed, 66 insertions(+), 39 deletions(-)

diff --git a/components/camel-aws/camel-aws2-ec2/src/generated/java/org/apache/camel/component/aws2/ec2/AWS2EC2ComponentConfigurer.java b/components/camel-aws/camel-aws2-ec2/src/generated/java/org/apache/camel/component/aws2/ec2/AWS2EC2ComponentConfigurer.java
index d650ea33c2f..8d6f97f0e79 100644
--- a/components/camel-aws/camel-aws2-ec2/src/generated/java/org/apache/camel/component/aws2/ec2/AWS2EC2ComponentConfigurer.java
+++ b/components/camel-aws/camel-aws2-ec2/src/generated/java/org/apache/camel/component/aws2/ec2/AWS2EC2ComponentConfigurer.java
@@ -35,6 +35,12 @@ public class AWS2EC2ComponentConfigurer extends PropertyConfigurerSupport implem
         case "autowiredenabled":
         case "autowiredEnabled": target.setAutowiredEnabled(property(camelContext, boolean.class, value)); return true;
         case "configuration": target.setConfiguration(property(camelContext, org.apache.camel.component.aws2.ec2.AWS2EC2Configuration.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 "operation": getOrCreateConfiguration(target).setOperation(property(camelContext, org.apache.camel.component.aws2.ec2.AWS2EC2Operations.class, value)); return true;
@@ -80,6 +86,12 @@ public class AWS2EC2ComponentConfigurer extends PropertyConfigurerSupport implem
         case "autowiredenabled":
         case "autowiredEnabled": return boolean.class;
         case "configuration": return org.apache.camel.component.aws2.ec2.AWS2EC2Configuration.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 "operation": return org.apache.camel.component.aws2.ec2.AWS2EC2Operations.class;
@@ -121,6 +133,12 @@ public class AWS2EC2ComponentConfigurer extends PropertyConfigurerSupport implem
         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 "operation": return getOrCreateConfiguration(target).getOperation();
diff --git a/components/camel-aws/camel-aws2-ec2/src/generated/resources/org/apache/camel/component/aws2/ec2/aws2-ec2.json b/components/camel-aws/camel-aws2-ec2/src/generated/resources/org/apache/camel/component/aws2/ec2/aws2-ec2.json
index d85692988d8..9e4ed24b199 100644
--- a/components/camel-aws/camel-aws2-ec2/src/generated/resources/org/apache/camel/component/aws2/ec2/aws2-ec2.json
+++ b/components/camel-aws/camel-aws2-ec2/src/generated/resources/org/apache/camel/component/aws2/ec2/aws2-ec2.json
@@ -39,7 +39,10 @@
     "uriEndpointOverride": { "index": 14, "kind": "property", "displayName": "Uri Endpoint Override", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.ec2.AWS2EC2Configuration", "configurationField": "configuration", "description": "Set the overriding uri endpoint. This option needs to be used in combination with overrideEn [...]
     "useDefaultCredentialsProvider": { "index": 15, "kind": "property", "displayName": "Use Default 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.ec2.AWS2EC2Configuration", "configurationField": "configuration", "description": "Set whether the EC2 client should expect to load credent [...]
     "useProfileCredentialsProvider": { "index": 16, "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.ec2.AWS2EC2Configuration", "configurationField": "configuration", "description": "Set whether the EC2 client should expect to load credent [...]
-    "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  [...]
+    "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  [...]
+    "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" }
   },
   "headers": {
     "CamelAwsEC2ImageId": { "index": 0, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "An image ID of the AWS marketplace", "constantName": "org.apache.camel.component.aws2.ec2.AWS2EC2Constants#IMAGE_ID" },
diff --git a/components/camel-aws/camel-aws2-ec2/src/main/java/org/apache/camel/component/aws2/ec2/AWS2EC2Component.java b/components/camel-aws/camel-aws2-ec2/src/main/java/org/apache/camel/component/aws2/ec2/AWS2EC2Component.java
index 70e1937fb67..1bff721da4d 100644
--- a/components/camel-aws/camel-aws2-ec2/src/main/java/org/apache/camel/component/aws2/ec2/AWS2EC2Component.java
+++ b/components/camel-aws/camel-aws2-ec2/src/main/java/org/apache/camel/component/aws2/ec2/AWS2EC2Component.java
@@ -22,13 +22,14 @@ 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's Elastic Compute Cloud (EC2) SDK v2.
  */
 @Component("aws2-ec2")
-public class AWS2EC2Component extends DefaultComponent {
+public class AWS2EC2Component extends HealthCheckComponent {
+
     @Metadata
     private AWS2EC2Configuration configuration = new AWS2EC2Configuration();
 
diff --git a/components/camel-aws/camel-aws2-ec2/src/main/java/org/apache/camel/component/aws2/ec2/AWS2EC2Endpoint.java b/components/camel-aws/camel-aws2-ec2/src/main/java/org/apache/camel/component/aws2/ec2/AWS2EC2Endpoint.java
index db01be8f392..f667171d164 100644
--- a/components/camel-aws/camel-aws2-ec2/src/main/java/org/apache/camel/component/aws2/ec2/AWS2EC2Endpoint.java
+++ b/components/camel-aws/camel-aws2-ec2/src/main/java/org/apache/camel/component/aws2/ec2/AWS2EC2Endpoint.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.ec2.client.AWS2EC2ClientFactory;
-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;
@@ -39,8 +37,6 @@ import software.amazon.awssdk.services.ec2.Ec2Client;
 public class AWS2EC2Endpoint extends DefaultEndpoint {
 
     private Ec2Client ec2Client;
-    private ComponentsHealthCheckRepository healthCheckRepository;
-    private AWS2EC2HealthCheck clientHealthCheck;
 
     @UriParam
     private AWS2EC2Configuration configuration;
@@ -66,15 +62,6 @@ public class AWS2EC2Endpoint extends DefaultEndpoint {
 
         ec2Client = configuration.getAmazonEc2Client() != null
                 ? configuration.getAmazonEc2Client() : AWS2EC2ClientFactory.getEc2Client(configuration).getEc2Client();
-
-        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 AWS2EC2HealthCheck(this, getId());
-            //healthCheckRepository.addHealthCheck(clientHealthCheck);
-        }
     }
 
     @Override
@@ -85,10 +72,6 @@ public class AWS2EC2Endpoint extends DefaultEndpoint {
             }
         }
 
-        if (healthCheckRepository != null && clientHealthCheck != null) {
-            healthCheckRepository.removeHealthCheck(clientHealthCheck);
-            clientHealthCheck = null;
-        }
         super.doStop();
     }
 
@@ -99,4 +82,9 @@ public class AWS2EC2Endpoint extends DefaultEndpoint {
     public Ec2Client getEc2Client() {
         return ec2Client;
     }
+
+    @Override
+    public AWS2EC2Component getComponent() {
+        return (AWS2EC2Component) super.getComponent();
+    }
 }
diff --git a/components/camel-aws/camel-aws2-ec2/src/main/java/org/apache/camel/component/aws2/ec2/AWS2EC2Producer.java b/components/camel-aws/camel-aws2-ec2/src/main/java/org/apache/camel/component/aws2/ec2/AWS2EC2Producer.java
index 194f3ae0b85..6eca5006d59 100644
--- a/components/camel-aws/camel-aws2-ec2/src/main/java/org/apache/camel/component/aws2/ec2/AWS2EC2Producer.java
+++ b/components/camel-aws/camel-aws2-ec2/src/main/java/org/apache/camel/component/aws2/ec2/AWS2EC2Producer.java
@@ -23,6 +23,8 @@ import org.apache.camel.Endpoint;
 import org.apache.camel.Exchange;
 import org.apache.camel.InvalidPayloadException;
 import org.apache.camel.Message;
+import org.apache.camel.health.HealthCheckHelper;
+import org.apache.camel.health.WritableHealthCheckRepository;
 import org.apache.camel.support.DefaultProducer;
 import org.apache.camel.util.ObjectHelper;
 import org.apache.camel.util.URISupport;
@@ -63,6 +65,8 @@ public class AWS2EC2Producer extends DefaultProducer {
 
     private static final Logger LOG = LoggerFactory.getLogger(AWS2EC2Producer.class);
 
+    private AWS2EC2ProducerHealthCheck producerHealthCheck;
+    private WritableHealthCheckRepository healthCheckRepository;
     private transient String ec2ProducerToString;
 
     public AWS2EC2Producer(Endpoint endpoint) {
@@ -642,4 +646,29 @@ public class AWS2EC2Producer extends DefaultProducer {
     public static Message getMessageForResponse(final Exchange exchange) {
         return exchange.getMessage();
     }
+
+    @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 AWS2EC2ProducerHealthCheck(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-ec2/src/main/java/org/apache/camel/component/aws2/ec2/AWS2EC2HealthCheck.java b/components/camel-aws/camel-aws2-ec2/src/main/java/org/apache/camel/component/aws2/ec2/AWS2EC2ProducerHealthCheck.java
similarity index 92%
rename from components/camel-aws/camel-aws2-ec2/src/main/java/org/apache/camel/component/aws2/ec2/AWS2EC2HealthCheck.java
rename to components/camel-aws/camel-aws2-ec2/src/main/java/org/apache/camel/component/aws2/ec2/AWS2EC2ProducerHealthCheck.java
index e4e1d463c6a..ea078fc9ca1 100644
--- a/components/camel-aws/camel-aws2-ec2/src/main/java/org/apache/camel/component/aws2/ec2/AWS2EC2HealthCheck.java
+++ b/components/camel-aws/camel-aws2-ec2/src/main/java/org/apache/camel/component/aws2/ec2/AWS2EC2ProducerHealthCheck.java
@@ -26,12 +26,12 @@ import software.amazon.awssdk.awscore.exception.AwsServiceException;
 import software.amazon.awssdk.regions.Region;
 import software.amazon.awssdk.services.ec2.Ec2Client;
 
-public class AWS2EC2HealthCheck extends AbstractHealthCheck {
+public class AWS2EC2ProducerHealthCheck extends AbstractHealthCheck {
 
     private final AWS2EC2Endpoint aws2EC2Endpoint;
 
-    public AWS2EC2HealthCheck(AWS2EC2Endpoint aws2EC2Endpoint, String clientId) {
-        super("camel", "aws2-ec2-client-" + clientId);
+    public AWS2EC2ProducerHealthCheck(AWS2EC2Endpoint aws2EC2Endpoint, String clientId) {
+        super("camel", "aws2-ec2-producer-" + clientId);
         this.aws2EC2Endpoint = aws2EC2Endpoint;
     }
 
diff --git a/components/camel-aws/camel-aws2-ec2/src/test/java/org/apache/camel/component/aws2/ec2/AWS2EC2HealthCheckProfileCredsTest.java b/components/camel-aws/camel-aws2-ec2/src/test/java/org/apache/camel/component/aws2/ec2/AWS2EC2ProducerHealthCheckProfileCredsTest.java
similarity index 90%
rename from components/camel-aws/camel-aws2-ec2/src/test/java/org/apache/camel/component/aws2/ec2/AWS2EC2HealthCheckProfileCredsTest.java
rename to components/camel-aws/camel-aws2-ec2/src/test/java/org/apache/camel/component/aws2/ec2/AWS2EC2ProducerHealthCheckProfileCredsTest.java
index c72f79e20fc..49ffb4ce094 100644
--- a/components/camel-aws/camel-aws2-ec2/src/test/java/org/apache/camel/component/aws2/ec2/AWS2EC2HealthCheckProfileCredsTest.java
+++ b/components/camel-aws/camel-aws2-ec2/src/test/java/org/apache/camel/component/aws2/ec2/AWS2EC2ProducerHealthCheckProfileCredsTest.java
@@ -29,14 +29,10 @@ 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 AWS2EC2HealthCheckProfileCredsTest extends CamelTestSupport {
-
-    private static final Logger LOG = LoggerFactory.getLogger(AWS2EC2HealthCheckProfileCredsTest.class);
+public class AWS2EC2ProducerHealthCheckProfileCredsTest extends CamelTestSupport {
 
     CamelContext context;
 
@@ -84,9 +80,7 @@ public class AWS2EC2HealthCheckProfileCredsTest extends CamelTestSupport {
             Collection<HealthCheck.Result> res2 = HealthCheckHelper.invokeReadiness(context);
             boolean down = res2.stream().allMatch(r -> r.getState().equals(HealthCheck.State.DOWN));
             boolean containsAws2AthenaHealthCheck = res2.stream()
-                    .filter(result -> result.getCheck().getId().startsWith("aws2-ec2-client"))
-                    .findAny()
-                    .isPresent();
+                    .anyMatch(result -> result.getCheck().getId().startsWith("aws2-ec2-producer"));
             boolean hasRegionMessage = res2.stream()
                     .anyMatch(r -> r.getMessage().stream().anyMatch(msg -> msg.contains("region")));
             Assertions.assertTrue(down, "liveness check");
diff --git a/components/camel-aws/camel-aws2-ec2/src/test/java/org/apache/camel/component/aws2/ec2/AWS2EC2HealthCheckStaticCredsTest.java b/components/camel-aws/camel-aws2-ec2/src/test/java/org/apache/camel/component/aws2/ec2/AWS2EC2ProducerHealthCheckStaticCredsTest.java
similarity index 90%
rename from components/camel-aws/camel-aws2-ec2/src/test/java/org/apache/camel/component/aws2/ec2/AWS2EC2HealthCheckStaticCredsTest.java
rename to components/camel-aws/camel-aws2-ec2/src/test/java/org/apache/camel/component/aws2/ec2/AWS2EC2ProducerHealthCheckStaticCredsTest.java
index ad815bc8d60..304247663de 100644
--- a/components/camel-aws/camel-aws2-ec2/src/test/java/org/apache/camel/component/aws2/ec2/AWS2EC2HealthCheckStaticCredsTest.java
+++ b/components/camel-aws/camel-aws2-ec2/src/test/java/org/apache/camel/component/aws2/ec2/AWS2EC2ProducerHealthCheckStaticCredsTest.java
@@ -29,14 +29,10 @@ 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 AWS2EC2HealthCheckStaticCredsTest extends CamelTestSupport {
-
-    private static final Logger LOG = LoggerFactory.getLogger(AWS2EC2HealthCheckStaticCredsTest.class);
+public class AWS2EC2ProducerHealthCheckStaticCredsTest extends CamelTestSupport {
 
     CamelContext context;
 
@@ -84,9 +80,7 @@ public class AWS2EC2HealthCheckStaticCredsTest extends CamelTestSupport {
             Collection<HealthCheck.Result> res2 = HealthCheckHelper.invokeReadiness(context);
             boolean down = res2.stream().allMatch(r -> r.getState().equals(HealthCheck.State.DOWN));
             boolean containsAws2AthenaHealthCheck = res2.stream()
-                    .filter(result -> result.getCheck().getId().startsWith("aws2-ec2-client"))
-                    .findAny()
-                    .isPresent();
+                    .anyMatch(result -> result.getCheck().getId().startsWith("aws2-ec2-producer"));
             boolean hasRegionMessage = res2.stream()
                     .anyMatch(r -> r.getMessage().stream().anyMatch(msg -> msg.contains("region")));
             Assertions.assertTrue(down, "liveness check");


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

Posted by da...@apache.org.
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 d0db4f0e9a36df2e954bc004a16d35c89452a9fc
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri Jul 28 09:48:35 2023 +0200

    CAMEL-19645: camel-aws - producer health check
---
 .../aws2/ecs/ECS2ComponentConfigurer.java          | 18 +++++++++++++
 .../apache/camel/component/aws2/ecs/aws2-ecs.json  |  7 +++--
 .../camel/component/aws2/ecs/ECS2Component.java    |  5 ++--
 .../camel/component/aws2/ecs/ECS2Endpoint.java     | 23 ++++------------
 .../camel/component/aws2/ecs/ECS2Producer.java     | 31 ++++++++++++++++++++++
 ...althCheck.java => ECS2ProducerHealthCheck.java} |  6 ++---
 ...> ECS2ProducerHealthCheckProfileCredsTest.java} | 10 +++----
 ...=> ECS2ProducerHealthCheckStaticCredsTest.java} | 10 +++----
 8 files changed, 71 insertions(+), 39 deletions(-)

diff --git a/components/camel-aws/camel-aws2-ecs/src/generated/java/org/apache/camel/component/aws2/ecs/ECS2ComponentConfigurer.java b/components/camel-aws/camel-aws2-ecs/src/generated/java/org/apache/camel/component/aws2/ecs/ECS2ComponentConfigurer.java
index f1b1614ef41..269a35377cd 100644
--- a/components/camel-aws/camel-aws2-ecs/src/generated/java/org/apache/camel/component/aws2/ecs/ECS2ComponentConfigurer.java
+++ b/components/camel-aws/camel-aws2-ecs/src/generated/java/org/apache/camel/component/aws2/ecs/ECS2ComponentConfigurer.java
@@ -35,6 +35,12 @@ public class ECS2ComponentConfigurer extends PropertyConfigurerSupport implement
         case "configuration": target.setConfiguration(property(camelContext, org.apache.camel.component.aws2.ecs.ECS2Configuration.class, value)); return true;
         case "ecsclient":
         case "ecsClient": getOrCreateConfiguration(target).setEcsClient(property(camelContext, software.amazon.awssdk.services.ecs.EcsClient.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 "operation": getOrCreateConfiguration(target).setOperation(property(camelContext, org.apache.camel.component.aws2.ecs.ECS2Operations.class, value)); return true;
@@ -80,6 +86,12 @@ public class ECS2ComponentConfigurer extends PropertyConfigurerSupport implement
         case "configuration": return org.apache.camel.component.aws2.ecs.ECS2Configuration.class;
         case "ecsclient":
         case "ecsClient": return software.amazon.awssdk.services.ecs.EcsClient.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 "operation": return org.apache.camel.component.aws2.ecs.ECS2Operations.class;
@@ -121,6 +133,12 @@ public class ECS2ComponentConfigurer extends PropertyConfigurerSupport implement
         case "configuration": return target.getConfiguration();
         case "ecsclient":
         case "ecsClient": return getOrCreateConfiguration(target).getEcsClient();
+        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 "operation": return getOrCreateConfiguration(target).getOperation();
diff --git a/components/camel-aws/camel-aws2-ecs/src/generated/resources/org/apache/camel/component/aws2/ecs/aws2-ecs.json b/components/camel-aws/camel-aws2-ecs/src/generated/resources/org/apache/camel/component/aws2/ecs/aws2-ecs.json
index cf6d913192c..791e53deeb2 100644
--- a/components/camel-aws/camel-aws2-ecs/src/generated/resources/org/apache/camel/component/aws2/ecs/aws2-ecs.json
+++ b/components/camel-aws/camel-aws2-ecs/src/generated/resources/org/apache/camel/component/aws2/ecs/aws2-ecs.json
@@ -38,8 +38,11 @@
     "useDefaultCredentialsProvider": { "index": 13, "kind": "property", "displayName": "Use Default 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.ecs.ECS2Configuration", "configurationField": "configuration", "description": "Set whether the ECS client should expect to load credential [...]
     "useProfileCredentialsProvider": { "index": 14, "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.ecs.ECS2Configuration", "configurationField": "configuration", "description": "Set whether the ECS client should expect to load credential [...]
     "autowiredEnabled": { "index": 15, "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": 16, "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.ecs.ECS2Configuration", "configurationField": "configuration", "description": "Amazon AWS Access Key" },
-    "secretKey": { "index": 17, "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.ecs.ECS2Configuration", "configurationField": "configuration", "description": "Amazon AWS Secret Key" }
+    "healthCheckConsumerEnabled": { "index": 16, "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": 17, "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": 18, "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": 19, "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.ecs.ECS2Configuration", "configurationField": "configuration", "description": "Amazon AWS Access Key" },
+    "secretKey": { "index": 20, "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.ecs.ECS2Configuration", "configurationField": "configuration", "description": "Amazon AWS Secret Key" }
   },
   "headers": {
     "CamelAwsECSOperation": { "index": 0, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The operation we want to perform", "constantName": "org.apache.camel.component.aws2.ecs.ECS2Constants#OPERATION" },
diff --git a/components/camel-aws/camel-aws2-ecs/src/main/java/org/apache/camel/component/aws2/ecs/ECS2Component.java b/components/camel-aws/camel-aws2-ecs/src/main/java/org/apache/camel/component/aws2/ecs/ECS2Component.java
index ee47c22dbd4..e47dbc4b5cc 100644
--- a/components/camel-aws/camel-aws2-ecs/src/main/java/org/apache/camel/component/aws2/ecs/ECS2Component.java
+++ b/components/camel-aws/camel-aws2-ecs/src/main/java/org/apache/camel/component/aws2/ecs/ECS2Component.java
@@ -22,13 +22,14 @@ 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 ECS SDK v2.
  */
 @Component("aws2-ecs")
-public class ECS2Component extends DefaultComponent {
+public class ECS2Component extends HealthCheckComponent {
+
     @Metadata
     private ECS2Configuration configuration = new ECS2Configuration();
 
diff --git a/components/camel-aws/camel-aws2-ecs/src/main/java/org/apache/camel/component/aws2/ecs/ECS2Endpoint.java b/components/camel-aws/camel-aws2-ecs/src/main/java/org/apache/camel/component/aws2/ecs/ECS2Endpoint.java
index 6b7b615437e..af1f33969cb 100644
--- a/components/camel-aws/camel-aws2-ecs/src/main/java/org/apache/camel/component/aws2/ecs/ECS2Endpoint.java
+++ b/components/camel-aws/camel-aws2-ecs/src/main/java/org/apache/camel/component/aws2/ecs/ECS2Endpoint.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.ecs.client.ECS2ClientFactory;
-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.ScheduledPollEndpoint;
@@ -39,8 +37,6 @@ import software.amazon.awssdk.services.ecs.EcsClient;
 public class ECS2Endpoint extends ScheduledPollEndpoint {
 
     private EcsClient ecsClient;
-    private ComponentsHealthCheckRepository healthCheckRepository;
-    private ECS2ClientHealthCheck clientHealthCheck;
 
     @UriParam
     private ECS2Configuration configuration;
@@ -50,6 +46,11 @@ public class ECS2Endpoint extends ScheduledPollEndpoint {
         this.configuration = configuration;
     }
 
+    @Override
+    public ECS2Component getComponent() {
+        return (ECS2Component) super.getComponent();
+    }
+
     @Override
     public Consumer createConsumer(Processor processor) throws Exception {
         throw new UnsupportedOperationException("You cannot receive messages from this endpoint");
@@ -66,24 +67,10 @@ public class ECS2Endpoint extends ScheduledPollEndpoint {
 
         ecsClient = configuration.getEcsClient() != null
                 ? configuration.getEcsClient() : ECS2ClientFactory.getEcsClient(configuration).getEcsClient();
-
-        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 ECS2ClientHealthCheck(this, getId());
-            //healthCheckRepository.addHealthCheck(clientHealthCheck);
-        }
     }
 
     @Override
     public void doStop() throws Exception {
-        if (healthCheckRepository != null && clientHealthCheck != null) {
-            healthCheckRepository.removeHealthCheck(clientHealthCheck);
-            clientHealthCheck = null;
-        }
-
         if (ObjectHelper.isEmpty(configuration.getEcsClient())) {
             if (ecsClient != null) {
                 ecsClient.close();
diff --git a/components/camel-aws/camel-aws2-ecs/src/main/java/org/apache/camel/component/aws2/ecs/ECS2Producer.java b/components/camel-aws/camel-aws2-ecs/src/main/java/org/apache/camel/component/aws2/ecs/ECS2Producer.java
index 8f1b06cf1e6..278458e541b 100644
--- a/components/camel-aws/camel-aws2-ecs/src/main/java/org/apache/camel/component/aws2/ecs/ECS2Producer.java
+++ b/components/camel-aws/camel-aws2-ecs/src/main/java/org/apache/camel/component/aws2/ecs/ECS2Producer.java
@@ -20,6 +20,9 @@ import org.apache.camel.Endpoint;
 import org.apache.camel.Exchange;
 import org.apache.camel.InvalidPayloadException;
 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;
 import org.apache.camel.util.ObjectHelper;
 import org.apache.camel.util.URISupport;
@@ -45,6 +48,8 @@ public class ECS2Producer extends DefaultProducer {
     private static final Logger LOG = LoggerFactory.getLogger(ECS2Producer.class);
 
     private transient String ecsProducerToString;
+    private HealthCheck producerHealthCheck;
+    private WritableHealthCheckRepository healthCheckRepository;
 
     public ECS2Producer(Endpoint endpoint) {
         super(endpoint);
@@ -236,4 +241,30 @@ public class ECS2Producer extends DefaultProducer {
     public static Message getMessageForResponse(final Exchange exchange) {
         return exchange.getMessage();
     }
+
+    @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 ECS2ProducerHealthCheck(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-ecs/src/main/java/org/apache/camel/component/aws2/ecs/ECS2ClientHealthCheck.java b/components/camel-aws/camel-aws2-ecs/src/main/java/org/apache/camel/component/aws2/ecs/ECS2ProducerHealthCheck.java
similarity index 92%
rename from components/camel-aws/camel-aws2-ecs/src/main/java/org/apache/camel/component/aws2/ecs/ECS2ClientHealthCheck.java
rename to components/camel-aws/camel-aws2-ecs/src/main/java/org/apache/camel/component/aws2/ecs/ECS2ProducerHealthCheck.java
index 75c4ea25fc2..d52e41418a6 100644
--- a/components/camel-aws/camel-aws2-ecs/src/main/java/org/apache/camel/component/aws2/ecs/ECS2ClientHealthCheck.java
+++ b/components/camel-aws/camel-aws2-ecs/src/main/java/org/apache/camel/component/aws2/ecs/ECS2ProducerHealthCheck.java
@@ -27,12 +27,12 @@ import software.amazon.awssdk.regions.Region;
 import software.amazon.awssdk.services.ecs.EcsClient;
 import software.amazon.awssdk.services.ecs.model.ListClustersRequest;
 
-public class ECS2ClientHealthCheck extends AbstractHealthCheck {
+public class ECS2ProducerHealthCheck extends AbstractHealthCheck {
 
     private final ECS2Endpoint ecs2Endpoint;
 
-    public ECS2ClientHealthCheck(ECS2Endpoint ecs2Endpoint, String clientId) {
-        super("camel", "aws2-ecs-client-" + clientId);
+    public ECS2ProducerHealthCheck(ECS2Endpoint ecs2Endpoint, String clientId) {
+        super("camel", "aws2-ecs-producer-" + clientId);
         this.ecs2Endpoint = ecs2Endpoint;
     }
 
diff --git a/components/camel-aws/camel-aws2-ecs/src/test/java/org/apache/camel/component/aws2/ecs/ECS2ClientHealthCheckProfileCredsTest.java b/components/camel-aws/camel-aws2-ecs/src/test/java/org/apache/camel/component/aws2/ecs/ECS2ProducerHealthCheckProfileCredsTest.java
similarity index 90%
rename from components/camel-aws/camel-aws2-ecs/src/test/java/org/apache/camel/component/aws2/ecs/ECS2ClientHealthCheckProfileCredsTest.java
rename to components/camel-aws/camel-aws2-ecs/src/test/java/org/apache/camel/component/aws2/ecs/ECS2ProducerHealthCheckProfileCredsTest.java
index 4a8fd77b302..e7c0df293e2 100644
--- a/components/camel-aws/camel-aws2-ecs/src/test/java/org/apache/camel/component/aws2/ecs/ECS2ClientHealthCheckProfileCredsTest.java
+++ b/components/camel-aws/camel-aws2-ecs/src/test/java/org/apache/camel/component/aws2/ecs/ECS2ProducerHealthCheckProfileCredsTest.java
@@ -28,16 +28,15 @@ 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.awaitility.Awaitility.await;
 
-public class ECS2ClientHealthCheckProfileCredsTest extends CamelTestSupport {
+public class ECS2ProducerHealthCheckProfileCredsTest extends CamelTestSupport {
 
-    private static final Logger LOG = LoggerFactory.getLogger(ECS2ClientHealthCheckProfileCredsTest.class);
+    private static final Logger LOG = LoggerFactory.getLogger(ECS2ProducerHealthCheckProfileCredsTest.class);
 
     CamelContext context;
 
@@ -73,7 +72,6 @@ public class ECS2ClientHealthCheckProfileCredsTest 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 +83,7 @@ public class ECS2ClientHealthCheckProfileCredsTest extends CamelTestSupport {
             Collection<HealthCheck.Result> res2 = HealthCheckHelper.invokeReadiness(context);
             boolean down = res2.stream().allMatch(r -> r.getState().equals(HealthCheck.State.DOWN));
             boolean containsAws2EcsHealthCheck = res2.stream()
-                    .filter(result -> result.getCheck().getId().startsWith("aws2-ecs-client"))
-                    .findAny()
-                    .isPresent();
+                    .anyMatch(result -> result.getCheck().getId().startsWith("aws2-ecs-producer"));
             boolean hasRegionMessage = res2.stream()
                     .anyMatch(r -> r.getMessage().stream().anyMatch(msg -> msg.contains("region")));
             Assertions.assertTrue(down, "liveness check");
diff --git a/components/camel-aws/camel-aws2-ecs/src/test/java/org/apache/camel/component/aws2/ecs/ECS2ClientHealthCheckStaticCredsTest.java b/components/camel-aws/camel-aws2-ecs/src/test/java/org/apache/camel/component/aws2/ecs/ECS2ProducerHealthCheckStaticCredsTest.java
similarity index 90%
rename from components/camel-aws/camel-aws2-ecs/src/test/java/org/apache/camel/component/aws2/ecs/ECS2ClientHealthCheckStaticCredsTest.java
rename to components/camel-aws/camel-aws2-ecs/src/test/java/org/apache/camel/component/aws2/ecs/ECS2ProducerHealthCheckStaticCredsTest.java
index 1853967095e..d8dcd13d56b 100644
--- a/components/camel-aws/camel-aws2-ecs/src/test/java/org/apache/camel/component/aws2/ecs/ECS2ClientHealthCheckStaticCredsTest.java
+++ b/components/camel-aws/camel-aws2-ecs/src/test/java/org/apache/camel/component/aws2/ecs/ECS2ProducerHealthCheckStaticCredsTest.java
@@ -28,16 +28,15 @@ 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.awaitility.Awaitility.await;
 
-public class ECS2ClientHealthCheckStaticCredsTest extends CamelTestSupport {
+public class ECS2ProducerHealthCheckStaticCredsTest extends CamelTestSupport {
 
-    private static final Logger LOG = LoggerFactory.getLogger(ECS2ClientHealthCheckStaticCredsTest.class);
+    private static final Logger LOG = LoggerFactory.getLogger(ECS2ProducerHealthCheckStaticCredsTest.class);
 
     CamelContext context;
 
@@ -73,7 +72,6 @@ public class ECS2ClientHealthCheckStaticCredsTest 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 +83,7 @@ public class ECS2ClientHealthCheckStaticCredsTest extends CamelTestSupport {
             Collection<HealthCheck.Result> res2 = HealthCheckHelper.invokeReadiness(context);
             boolean down = res2.stream().allMatch(r -> r.getState().equals(HealthCheck.State.DOWN));
             boolean containsAws2EcsHealthCheck = res2.stream()
-                    .filter(result -> result.getCheck().getId().startsWith("aws2-ecs-client"))
-                    .findAny()
-                    .isPresent();
+                    .anyMatch(result -> result.getCheck().getId().startsWith("aws2-ecs-producer"));
             boolean hasRegionMessage = res2.stream()
                     .anyMatch(r -> r.getMessage().stream().anyMatch(msg -> msg.contains("region")));
             Assertions.assertTrue(down, "liveness check");


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

Posted by da...@apache.org.
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 ea264fd327a5c8e6bc43df962332d43ff42bd8fa
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri Jul 28 09:54:28 2023 +0200

    CAMEL-19645: camel-aws - producer health check
---
 .../aws2/eks/EKS2ComponentConfigurer.java          | 18 +++++++++++++
 .../apache/camel/component/aws2/eks/aws2-eks.json  |  7 +++--
 .../camel/component/aws2/eks/EKS2Component.java    |  5 ++--
 .../camel/component/aws2/eks/EKS2Endpoint.java     | 23 ++++------------
 .../camel/component/aws2/eks/EKS2Producer.java     | 31 ++++++++++++++++++++++
 ...althCheck.java => EKS2ProducerHealthCheck.java} |  6 ++---
 ...> EKS2ProducerHealthCheckProfileCredsTest.java} | 13 ++-------
 ...=> EKS2ProducerHealthCheckStaticCredsTest.java} | 12 ++-------
 8 files changed, 69 insertions(+), 46 deletions(-)

diff --git a/components/camel-aws/camel-aws2-eks/src/generated/java/org/apache/camel/component/aws2/eks/EKS2ComponentConfigurer.java b/components/camel-aws/camel-aws2-eks/src/generated/java/org/apache/camel/component/aws2/eks/EKS2ComponentConfigurer.java
index f70f9afd3f9..a388cd6adea 100644
--- a/components/camel-aws/camel-aws2-eks/src/generated/java/org/apache/camel/component/aws2/eks/EKS2ComponentConfigurer.java
+++ b/components/camel-aws/camel-aws2-eks/src/generated/java/org/apache/camel/component/aws2/eks/EKS2ComponentConfigurer.java
@@ -35,6 +35,12 @@ public class EKS2ComponentConfigurer extends PropertyConfigurerSupport implement
         case "configuration": target.setConfiguration(property(camelContext, org.apache.camel.component.aws2.eks.EKS2Configuration.class, value)); return true;
         case "eksclient":
         case "eksClient": getOrCreateConfiguration(target).setEksClient(property(camelContext, software.amazon.awssdk.services.eks.EksClient.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 "operation": getOrCreateConfiguration(target).setOperation(property(camelContext, org.apache.camel.component.aws2.eks.EKS2Operations.class, value)); return true;
@@ -80,6 +86,12 @@ public class EKS2ComponentConfigurer extends PropertyConfigurerSupport implement
         case "configuration": return org.apache.camel.component.aws2.eks.EKS2Configuration.class;
         case "eksclient":
         case "eksClient": return software.amazon.awssdk.services.eks.EksClient.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 "operation": return org.apache.camel.component.aws2.eks.EKS2Operations.class;
@@ -121,6 +133,12 @@ public class EKS2ComponentConfigurer extends PropertyConfigurerSupport implement
         case "configuration": return target.getConfiguration();
         case "eksclient":
         case "eksClient": return getOrCreateConfiguration(target).getEksClient();
+        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 "operation": return getOrCreateConfiguration(target).getOperation();
diff --git a/components/camel-aws/camel-aws2-eks/src/generated/resources/org/apache/camel/component/aws2/eks/aws2-eks.json b/components/camel-aws/camel-aws2-eks/src/generated/resources/org/apache/camel/component/aws2/eks/aws2-eks.json
index fea921f0b44..ec6cacc4173 100644
--- a/components/camel-aws/camel-aws2-eks/src/generated/resources/org/apache/camel/component/aws2/eks/aws2-eks.json
+++ b/components/camel-aws/camel-aws2-eks/src/generated/resources/org/apache/camel/component/aws2/eks/aws2-eks.json
@@ -38,8 +38,11 @@
     "useDefaultCredentialsProvider": { "index": 13, "kind": "property", "displayName": "Use Default 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.eks.EKS2Configuration", "configurationField": "configuration", "description": "Set whether the EKS client should expect to load credential [...]
     "useProfileCredentialsProvider": { "index": 14, "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.eks.EKS2Configuration", "configurationField": "configuration", "description": "Set whether the EKS client should expect to load credential [...]
     "autowiredEnabled": { "index": 15, "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": 16, "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.eks.EKS2Configuration", "configurationField": "configuration", "description": "Amazon AWS Access Key" },
-    "secretKey": { "index": 17, "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.eks.EKS2Configuration", "configurationField": "configuration", "description": "Amazon AWS Secret Key" }
+    "healthCheckConsumerEnabled": { "index": 16, "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": 17, "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": 18, "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": 19, "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.eks.EKS2Configuration", "configurationField": "configuration", "description": "Amazon AWS Access Key" },
+    "secretKey": { "index": 20, "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.eks.EKS2Configuration", "configurationField": "configuration", "description": "Amazon AWS Secret Key" }
   },
   "headers": {
     "CamelAwsEKSOperation": { "index": 0, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The operation we want to perform", "constantName": "org.apache.camel.component.aws2.eks.EKS2Constants#OPERATION" },
diff --git a/components/camel-aws/camel-aws2-eks/src/main/java/org/apache/camel/component/aws2/eks/EKS2Component.java b/components/camel-aws/camel-aws2-eks/src/main/java/org/apache/camel/component/aws2/eks/EKS2Component.java
index d67bd10d79f..3473c54866a 100644
--- a/components/camel-aws/camel-aws2-eks/src/main/java/org/apache/camel/component/aws2/eks/EKS2Component.java
+++ b/components/camel-aws/camel-aws2-eks/src/main/java/org/apache/camel/component/aws2/eks/EKS2Component.java
@@ -22,13 +22,14 @@ 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 EKS SDK v2.
  */
 @Component("aws2-eks")
-public class EKS2Component extends DefaultComponent {
+public class EKS2Component extends HealthCheckComponent {
+
     @Metadata
     private EKS2Configuration configuration = new EKS2Configuration();
 
diff --git a/components/camel-aws/camel-aws2-eks/src/main/java/org/apache/camel/component/aws2/eks/EKS2Endpoint.java b/components/camel-aws/camel-aws2-eks/src/main/java/org/apache/camel/component/aws2/eks/EKS2Endpoint.java
index 6d20b1815ca..f825c02c739 100644
--- a/components/camel-aws/camel-aws2-eks/src/main/java/org/apache/camel/component/aws2/eks/EKS2Endpoint.java
+++ b/components/camel-aws/camel-aws2-eks/src/main/java/org/apache/camel/component/aws2/eks/EKS2Endpoint.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.eks.client.EKS2ClientFactory;
-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.ScheduledPollEndpoint;
@@ -39,8 +37,6 @@ import software.amazon.awssdk.services.eks.EksClient;
 public class EKS2Endpoint extends ScheduledPollEndpoint {
 
     private EksClient eksClient;
-    private ComponentsHealthCheckRepository healthCheckRepository;
-    private EKS2ClientHealthCheck clientHealthCheck;
 
     @UriParam
     private EKS2Configuration configuration;
@@ -60,30 +56,21 @@ public class EKS2Endpoint extends ScheduledPollEndpoint {
         return new EKS2Producer(this);
     }
 
+    @Override
+    public EKS2Component getComponent() {
+        return (EKS2Component) super.getComponent();
+    }
+
     @Override
     public void doStart() throws Exception {
         super.doStart();
 
         eksClient = configuration.getEksClient() != null
                 ? configuration.getEksClient() : EKS2ClientFactory.getEksClient(configuration).getEksClient();
-
-        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 EKS2ClientHealthCheck(this, getId());
-            // healthCheckRepository.addHealthCheck(clientHealthCheck);
-        }
     }
 
     @Override
     public void doStop() throws Exception {
-        if (healthCheckRepository != null && clientHealthCheck != null) {
-            healthCheckRepository.removeHealthCheck(clientHealthCheck);
-            clientHealthCheck = null;
-        }
-
         if (ObjectHelper.isEmpty(configuration.getEksClient())) {
             if (eksClient != null) {
                 eksClient.close();
diff --git a/components/camel-aws/camel-aws2-eks/src/main/java/org/apache/camel/component/aws2/eks/EKS2Producer.java b/components/camel-aws/camel-aws2-eks/src/main/java/org/apache/camel/component/aws2/eks/EKS2Producer.java
index a6f1755d96f..892095f480a 100644
--- a/components/camel-aws/camel-aws2-eks/src/main/java/org/apache/camel/component/aws2/eks/EKS2Producer.java
+++ b/components/camel-aws/camel-aws2-eks/src/main/java/org/apache/camel/component/aws2/eks/EKS2Producer.java
@@ -20,6 +20,9 @@ import org.apache.camel.Endpoint;
 import org.apache.camel.Exchange;
 import org.apache.camel.InvalidPayloadException;
 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;
 import org.apache.camel.util.ObjectHelper;
 import org.apache.camel.util.URISupport;
@@ -44,6 +47,8 @@ public class EKS2Producer extends DefaultProducer {
 
     private static final Logger LOG = LoggerFactory.getLogger(EKS2Producer.class);
     private transient String eksProducerToString;
+    private HealthCheck producerHealthCheck;
+    private WritableHealthCheckRepository healthCheckRepository;
 
     public EKS2Producer(Endpoint endpoint) {
         super(endpoint);
@@ -237,4 +242,30 @@ public class EKS2Producer extends DefaultProducer {
     public static Message getMessageForResponse(final Exchange exchange) {
         return exchange.getMessage();
     }
+
+    @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 EKS2ProducerHealthCheck(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-eks/src/main/java/org/apache/camel/component/aws2/eks/EKS2ClientHealthCheck.java b/components/camel-aws/camel-aws2-eks/src/main/java/org/apache/camel/component/aws2/eks/EKS2ProducerHealthCheck.java
similarity index 92%
rename from components/camel-aws/camel-aws2-eks/src/main/java/org/apache/camel/component/aws2/eks/EKS2ClientHealthCheck.java
rename to components/camel-aws/camel-aws2-eks/src/main/java/org/apache/camel/component/aws2/eks/EKS2ProducerHealthCheck.java
index 3f094582d18..cb37ec160de 100644
--- a/components/camel-aws/camel-aws2-eks/src/main/java/org/apache/camel/component/aws2/eks/EKS2ClientHealthCheck.java
+++ b/components/camel-aws/camel-aws2-eks/src/main/java/org/apache/camel/component/aws2/eks/EKS2ProducerHealthCheck.java
@@ -27,12 +27,12 @@ import software.amazon.awssdk.regions.Region;
 import software.amazon.awssdk.services.eks.EksClient;
 import software.amazon.awssdk.services.eks.model.ListClustersRequest;
 
-public class EKS2ClientHealthCheck extends AbstractHealthCheck {
+public class EKS2ProducerHealthCheck extends AbstractHealthCheck {
 
     private final EKS2Endpoint eks2Endpoint;
 
-    public EKS2ClientHealthCheck(EKS2Endpoint eks2Endpoint, String clientId) {
-        super("camel", "aws2-eks-client-" + clientId);
+    public EKS2ProducerHealthCheck(EKS2Endpoint eks2Endpoint, String clientId) {
+        super("camel", "aws2-eks-producer-" + clientId);
         this.eks2Endpoint = eks2Endpoint;
     }
 
diff --git a/components/camel-aws/camel-aws2-eks/src/test/java/org/apache/camel/component/aws2/eks/EKS2CliientHealthCheckProfileCredsTest.java b/components/camel-aws/camel-aws2-eks/src/test/java/org/apache/camel/component/aws2/eks/EKS2ProducerHealthCheckProfileCredsTest.java
similarity index 87%
rename from components/camel-aws/camel-aws2-eks/src/test/java/org/apache/camel/component/aws2/eks/EKS2CliientHealthCheckProfileCredsTest.java
rename to components/camel-aws/camel-aws2-eks/src/test/java/org/apache/camel/component/aws2/eks/EKS2ProducerHealthCheckProfileCredsTest.java
index 7d5397631cc..b137373673c 100644
--- a/components/camel-aws/camel-aws2-eks/src/test/java/org/apache/camel/component/aws2/eks/EKS2CliientHealthCheckProfileCredsTest.java
+++ b/components/camel-aws/camel-aws2-eks/src/test/java/org/apache/camel/component/aws2/eks/EKS2ProducerHealthCheckProfileCredsTest.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 EKS2CliientHealthCheckProfileCredsTest extends CamelTestSupport {
-
-    private static final Logger LOG = LoggerFactory.getLogger(EKS2CliientHealthCheckProfileCredsTest.class);
+public class EKS2ProducerHealthCheckProfileCredsTest extends CamelTestSupport {
 
     CamelContext context;
 
@@ -73,9 +68,7 @@ public class EKS2CliientHealthCheckProfileCredsTest 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);
         boolean up = res.stream().allMatch(r -> r.getState().equals(HealthCheck.State.UP));
         Assertions.assertTrue(up, "liveness check");
@@ -85,9 +78,7 @@ public class EKS2CliientHealthCheckProfileCredsTest extends CamelTestSupport {
             Collection<HealthCheck.Result> res2 = HealthCheckHelper.invokeReadiness(context);
             boolean down = res2.stream().allMatch(r -> r.getState().equals(HealthCheck.State.DOWN));
             boolean containsAws2AthenaHealthCheck = res2.stream()
-                    .filter(result -> result.getCheck().getId().startsWith("aws2-eks-client"))
-                    .findAny()
-                    .isPresent();
+                    .anyMatch(result -> result.getCheck().getId().startsWith("aws2-eks-producer"));
             boolean hasRegionMessage = res2.stream()
                     .anyMatch(r -> r.getMessage().stream().anyMatch(msg -> msg.contains("region")));
             Assertions.assertTrue(down, "liveness check");
diff --git a/components/camel-aws/camel-aws2-eks/src/test/java/org/apache/camel/component/aws2/eks/EKS2CliientHealthCheckStaticCredsTest.java b/components/camel-aws/camel-aws2-eks/src/test/java/org/apache/camel/component/aws2/eks/EKS2ProducerHealthCheckStaticCredsTest.java
similarity index 87%
rename from components/camel-aws/camel-aws2-eks/src/test/java/org/apache/camel/component/aws2/eks/EKS2CliientHealthCheckStaticCredsTest.java
rename to components/camel-aws/camel-aws2-eks/src/test/java/org/apache/camel/component/aws2/eks/EKS2ProducerHealthCheckStaticCredsTest.java
index deeceeb2200..a1592744be9 100644
--- a/components/camel-aws/camel-aws2-eks/src/test/java/org/apache/camel/component/aws2/eks/EKS2CliientHealthCheckStaticCredsTest.java
+++ b/components/camel-aws/camel-aws2-eks/src/test/java/org/apache/camel/component/aws2/eks/EKS2ProducerHealthCheckStaticCredsTest.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 EKS2CliientHealthCheckStaticCredsTest extends CamelTestSupport {
-
-    private static final Logger LOG = LoggerFactory.getLogger(EKS2CliientHealthCheckStaticCredsTest.class);
+public class EKS2ProducerHealthCheckStaticCredsTest extends CamelTestSupport {
 
     CamelContext context;
 
@@ -73,7 +68,6 @@ public class EKS2CliientHealthCheckStaticCredsTest 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 EKS2CliientHealthCheckStaticCredsTest extends CamelTestSupport {
             Collection<HealthCheck.Result> res2 = HealthCheckHelper.invokeReadiness(context);
             boolean down = res2.stream().allMatch(r -> r.getState().equals(HealthCheck.State.DOWN));
             boolean containsAws2AthenaHealthCheck = res2.stream()
-                    .filter(result -> result.getCheck().getId().startsWith("aws2-eks-client"))
-                    .findAny()
-                    .isPresent();
+                    .anyMatch(result -> result.getCheck().getId().startsWith("aws2-eks-producer"));
             boolean hasRegionMessage = res2.stream()
                     .anyMatch(r -> r.getMessage().stream().anyMatch(msg -> msg.contains("region")));
             Assertions.assertTrue(down, "liveness check");