You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2023/02/01 12:50:07 UTC
[camel] 03/06: CAMEL-18131 - camel-health - Add health checks for components that has extension for connectivity verification - AWS MQ
This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a commit to branch camel-3.20.x
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 8a7422915d32f08c70eb3e738894dfa4bc145aa7
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Feb 1 13:39:33 2023 +0100
CAMEL-18131 - camel-health - Add health checks for components that has extension for connectivity verification - AWS MQ
Signed-off-by: Andrea Cosentino <an...@gmail.com>
---
.../apache/camel/component/aws2/mq/MQ2Endpoint.java | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
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 33fd6c0cb46..b5750627a9c 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,6 +22,8 @@ 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;
@@ -37,6 +39,9 @@ public class MQ2Endpoint extends ScheduledPollEndpoint {
private MqClient mqClient;
+ private ComponentsHealthCheckRepository healthCheckRepository;
+ private MQ2ClientHealthCheck clientHealthCheck;
+
@UriParam
private MQ2Configuration configuration;
@@ -62,10 +67,23 @@ 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) {
+ 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();