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 2021/11/05 08:41:13 UTC
[camel-spring-boot] branch main updated: CAMEL-15333: camel-health
- Consumers have their own health-check-repo. Make it possible to turn them
off, and have similar configuration like routes.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-spring-boot.git
The following commit(s) were added to refs/heads/main by this push:
new a8c6383 CAMEL-15333: camel-health - Consumers have their own health-check-repo. Make it possible to turn them off, and have similar configuration like routes.
a8c6383 is described below
commit a8c63830cc2927f9568218ee6da9b1381de128f9
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri Nov 5 09:41:01 2021 +0100
CAMEL-15333: camel-health - Consumers have their own health-check-repo. Make it possible to turn them off, and have similar configuration like routes.
---
.../src/main/docs/spring-boot.json | 16 +++++++++----
.../health/CamelHealthCheckAutoConfiguration.java | 26 +++++++++++++++------
.../CamelHealthCheckConfigurationProperties.java | 27 ++++++++++++++++++----
3 files changed, 52 insertions(+), 17 deletions(-)
diff --git a/core/camel-spring-boot/src/main/docs/spring-boot.json b/core/camel-spring-boot/src/main/docs/spring-boot.json
index 348c994..a43fd39 100644
--- a/core/camel-spring-boot/src/main/docs/spring-boot.json
+++ b/core/camel-spring-boot/src/main/docs/spring-boot.json
@@ -397,7 +397,7 @@
{
"name": "camel.health.config",
"type": "java.util.Map<java.lang.String,org.apache.camel.spring.boot.actuate.health.CamelHealthCheckConfigurationProperties$HealthCheckConfigurationProperties>",
- "description": "Additional health check properties for fine grained configuration of health checks.",
+ "description": "Additional health check properties for fine-grained configuration of health checks.",
"sourceType": "org.apache.camel.spring.boot.actuate.health.CamelHealthCheckConfigurationProperties"
},
{
@@ -425,27 +425,33 @@
"sourceType": "org.apache.camel.spring.boot.actuate.health.CamelHealthCheckConfigurationProperties$HealthCheckConfigurationProperties"
},
{
+ "name": "camel.health.consumers-enabled",
+ "type": "java.lang.Boolean",
+ "description": "Whether consumers health check is enabled. Is default enabled",
+ "sourceType": "org.apache.camel.spring.boot.actuate.health.CamelHealthCheckConfigurationProperties"
+ },
+ {
"name": "camel.health.context-enabled",
"type": "java.lang.Boolean",
- "description": "Whether context health check is enabled Is default enabled",
+ "description": "Whether context health check is enabled. Is default enabled",
"sourceType": "org.apache.camel.spring.boot.actuate.health.CamelHealthCheckConfigurationProperties"
},
{
"name": "camel.health.enabled",
"type": "java.lang.Boolean",
- "description": "Whether health check is enabled globally",
+ "description": "Whether health check is enabled globally. Is default enabled",
"sourceType": "org.apache.camel.spring.boot.actuate.health.CamelHealthCheckConfigurationProperties"
},
{
"name": "camel.health.registry-enabled",
"type": "java.lang.Boolean",
- "description": "Whether registry health check is enabled Is default enabled",
+ "description": "Whether registry health check is enabled. Is default enabled",
"sourceType": "org.apache.camel.spring.boot.actuate.health.CamelHealthCheckConfigurationProperties"
},
{
"name": "camel.health.routes-enabled",
"type": "java.lang.Boolean",
- "description": "Whether routes health check is enabled Is default enabled",
+ "description": "Whether routes health check is enabled. Is default enabled",
"sourceType": "org.apache.camel.spring.boot.actuate.health.CamelHealthCheckConfigurationProperties"
},
{
diff --git a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/health/CamelHealthCheckAutoConfiguration.java b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/health/CamelHealthCheckAutoConfiguration.java
index c232eef..c5c6351 100644
--- a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/health/CamelHealthCheckAutoConfiguration.java
+++ b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/health/CamelHealthCheckAutoConfiguration.java
@@ -77,7 +77,7 @@ public class CamelHealthCheckAutoConfiguration {
hcr.register(hc);
}
}
- // routes is enabled by default
+ // routes are enabled by default
if (hcr.isEnabled() && (!config.getConfig().containsKey("routes") || config.getRoutesEnabled() != null)) {
HealthCheckRepository hc = hcr.getRepository("routes").orElse((HealthCheckRepository) hcr.resolveById("routes"));
if (hc != null) {
@@ -87,14 +87,26 @@ public class CamelHealthCheckAutoConfiguration {
hcr.register(hc);
}
}
- // registry is enabled by default
- final CamelHealthCheckConfigurationProperties lambdaConfig = config;
+ // consumers are enabled by default
+ if (hcr.isEnabled() && (!config.getConfig().containsKey("consumers") || config.getConsumersEnabled() != null)) {
+ HealthCheckRepository hc = hcr.getRepository("consumers").orElse((HealthCheckRepository) hcr.resolveById("consumers"));
+ if (hc != null) {
+ if (config.getConsumersEnabled() != null) {
+ hc.setEnabled(config.getConsumersEnabled());
+ }
+ hcr.register(hc);
+ }
+ }
+ // registry are enabled by default
if (hcr.isEnabled() && (!config.getConfig().containsKey("registry") || config.getRegistryEnabled() != null)) {
- hcr.getRepository("registry").ifPresent(h -> {
- if (lambdaConfig.getRegistryEnabled() != null) {
- h.setEnabled(lambdaConfig.getRegistryEnabled());
+ HealthCheckRepository hc
+ = hcr.getRepository("registry").orElse((HealthCheckRepository) hcr.resolveById("registry"));
+ if (hc != null) {
+ if (config.getRegistryEnabled() != null) {
+ hc.setEnabled(config.getRegistryEnabled());
}
- });
+ hcr.register(hc);
+ }
}
// configure health checks configurations
diff --git a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/health/CamelHealthCheckConfigurationProperties.java b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/health/CamelHealthCheckConfigurationProperties.java
index 7fd7637..435161c 100644
--- a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/health/CamelHealthCheckConfigurationProperties.java
+++ b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/health/CamelHealthCheckConfigurationProperties.java
@@ -26,33 +26,42 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
public class CamelHealthCheckConfigurationProperties {
/**
- * Whether health check is enabled globally
+ * Whether health check is enabled globally.
+ *
+ * Is default enabled
*/
private Boolean enabled;
/**
- * Whether context health check is enabled
+ * Whether context health check is enabled.
*
* Is default enabled
*/
private Boolean contextEnabled;
/**
- * Whether routes health check is enabled
+ * Whether routes health check is enabled.
*
* Is default enabled
*/
private Boolean routesEnabled;
/**
- * Whether registry health check is enabled
+ * Whether consumers health check is enabled.
+ *
+ * Is default enabled
+ */
+ private Boolean consumersEnabled;
+
+ /**
+ * Whether registry health check is enabled.
*
* Is default enabled
*/
private Boolean registryEnabled;
/**
- * Additional health check properties for fine grained configuration of health checks.
+ * Additional health check properties for fine-grained configuration of health checks.
*/
private Map<String, HealthCheckConfigurationProperties> config = new HashMap<>();
@@ -80,6 +89,14 @@ public class CamelHealthCheckConfigurationProperties {
this.routesEnabled = routesEnabled;
}
+ public Boolean getConsumersEnabled() {
+ return consumersEnabled;
+ }
+
+ public void setConsumersEnabled(Boolean consumersEnabled) {
+ this.consumersEnabled = consumersEnabled;
+ }
+
public Boolean getRegistryEnabled() {
return registryEnabled;
}