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 2025/07/29 20:17:42 UTC
(camel) branch man created (now de32a10bb4a)
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a change to branch man
in repository https://gitbox.apache.org/repos/asf/camel.git
at de32a10bb4a CAMEL-22285: platform-http-main - Dev consoles should be registered as management endpoints
This branch includes the following new commits:
new bda8aa40f0c CAMEL-22285: platform-http-main - Dev consoles should be registered as management endpoints
new 676f9889fd5 CAMEL-22285: platform-http-main - Dev consoles should be registered as management endpoints
new 0008c53e5d7 CAMEL-22285: platform-http-main - Dev consoles should be registered as management endpoints
new a732fdc0b53 CAMEL-22285: platform-http-main - Dev consoles should be registered as management endpoints
new 8fc7653ceda CAMEL-22285: platform-http-main - Dev consoles should be registered as management endpoints
new c4aeba686c1 CAMEL-22285: platform-http-main - Dev consoles should be registered as management endpoints
new ab6ee2e99bf CAMEL-22285: platform-http-main - Dev consoles should be registered as management endpoints
new de96f05c311 CAMEL-22285: platform-http-main - Dev consoles should be registered as management endpoints
new d5ccecde4f7 CAMEL-22285: platform-http-main - Dev consoles should be registered as management endpoints
new 719be35048d CAMEL-22285: platform-http-main - Dev consoles should be registered as management endpoints
new 94b1a50f748 CAMEL-22285: platform-http-main - Dev consoles should be registered as management endpoints
new 0d01f98eaa3 CAMEL-22285: platform-http-main - Dev consoles should be registered as management endpoints
new e02bfadeb59 CAMEL-22285: platform-http-main - Dev consoles should be registered as management endpoints
new e17268f78f9 CAMEL-22285: platform-http-main - Dev consoles should be registered as management endpoints
new de32a10bb4a CAMEL-22285: platform-http-main - Dev consoles should be registered as management endpoints
The 15 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) 08/15: CAMEL-22285: platform-http-main - Dev consoles should be registered as management endpoints
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch man
in repository https://gitbox.apache.org/repos/asf/camel.git
commit de96f05c311aacce394b37d72f3fb41afd9292be
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Jul 29 18:23:23 2025 +0200
CAMEL-22285: platform-http-main - Dev consoles should be registered as management endpoints
---
.../component/platform/http/PlatformHttpConsole.java | 20 +++++++++++++++++---
.../core/commands/process/ListPlatformHttp.java | 20 ++++++++++++++++++++
2 files changed, 37 insertions(+), 3 deletions(-)
diff --git a/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/PlatformHttpConsole.java b/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/PlatformHttpConsole.java
index 898537976b2..edb1358419c 100644
--- a/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/PlatformHttpConsole.java
+++ b/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/PlatformHttpConsole.java
@@ -45,6 +45,7 @@ public class PlatformHttpConsole extends AbstractDevConsole {
if (port > 0) {
server += ":" + port;
}
+ sb.append("Endpoints:\n");
Set<HttpEndpointModel> models = http.getHttpEndpoints();
for (HttpEndpointModel model : models) {
if (model.getVerbs() != null) {
@@ -53,6 +54,15 @@ public class PlatformHttpConsole extends AbstractDevConsole {
sb.append(String.format(" %s%s\n", server, model.getUri()));
}
}
+ sb.append("\nManagement Endpoints:\n");
+ models = http.getHttpManagementEndpoints();
+ for (HttpEndpointModel model : models) {
+ if (model.getVerbs() != null) {
+ sb.append(String.format(" %s%s (%s)\n", server, model.getUri(), model.getVerbs()));
+ } else {
+ sb.append(String.format(" %s%s\n", server, model.getUri()));
+ }
+ }
}
return sb.toString();
@@ -73,17 +83,21 @@ public class PlatformHttpConsole extends AbstractDevConsole {
}
root.put("server", server);
- final List<JsonObject> list = buildEndpointList(http, server);
+ List<JsonObject> list = buildEndpointList(http, server, false);
if (!list.isEmpty()) {
root.put("endpoints", list);
}
+ list = buildEndpointList(http, server, true);
+ if (!list.isEmpty()) {
+ root.put("managementEndpoints", list);
+ }
}
return root;
}
- private static List<JsonObject> buildEndpointList(PlatformHttpComponent http, String server) {
- Set<HttpEndpointModel> models = http.getHttpEndpoints();
+ private static List<JsonObject> buildEndpointList(PlatformHttpComponent http, String server, boolean management) {
+ Set<HttpEndpointModel> models = management ? http.getHttpManagementEndpoints() : http.getHttpEndpoints();
List<JsonObject> list = new ArrayList<>();
for (HttpEndpointModel model : models) {
JsonObject jo = new JsonObject();
diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/ListPlatformHttp.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/ListPlatformHttp.java
index da757cbd940..76a5826e891 100644
--- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/ListPlatformHttp.java
+++ b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/ListPlatformHttp.java
@@ -45,6 +45,10 @@ public class ListPlatformHttp extends ProcessWatchCommand {
description = "Sort by pid, name or age", defaultValue = "pid")
String sort;
+ @CommandLine.Option(names = { "--all" },
+ description = "Include management endpoints")
+ boolean all;
+
public ListPlatformHttp(CamelJBangMain main) {
super(main);
}
@@ -90,6 +94,22 @@ public class ListPlatformHttp extends ProcessWatchCommand {
rows.add(row);
}
}
+ if (all) {
+ arr = (JsonArray) jo.get("managementEndpoints");
+ if (arr != null) {
+ for (int i = 0; i < arr.size(); i++) {
+ row = row.copy();
+ jo = (JsonObject) arr.get(i);
+ row.server = server;
+ row.url = jo.getString("url");
+ row.path = jo.getString("path");
+ row.verbs = jo.getString("verbs");
+ row.consumes = jo.getString("consumes");
+ row.produces = jo.getString("produces");
+ rows.add(row);
+ }
+ }
+ }
}
}
});
(camel) 11/15: CAMEL-22285: platform-http-main - Dev consoles should be registered as management endpoints
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch man
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 94b1a50f74844f22121ccf15493eedff85d9f72d
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Jul 29 19:53:56 2025 +0200
CAMEL-22285: platform-http-main - Dev consoles should be registered as management endpoints
---
.../camel-micrometer/src/main/docs/micrometer-component.adoc | 6 +++---
.../camel/dsl/jbang/core/commands/ExportBaseCommand.java | 7 +++++--
.../camel/dsl/jbang/core/commands/ExportCamelMain.java | 12 ++++++++++--
.../apache/camel/dsl/jbang/core/commands/ExportQuarkus.java | 4 ++--
.../camel/dsl/jbang/core/commands/ExportSpringBoot.java | 4 ++--
5 files changed, 22 insertions(+), 11 deletions(-)
diff --git a/components/camel-micrometer/src/main/docs/micrometer-component.adoc b/components/camel-micrometer/src/main/docs/micrometer-component.adoc
index 39f0e653d86..b7f4c706759 100644
--- a/components/camel-micrometer/src/main/docs/micrometer-component.adoc
+++ b/components/camel-micrometer/src/main/docs/micrometer-component.adoc
@@ -585,9 +585,9 @@ And easily enable and configure this from `application.properties` as shown:
[source,properties]
----
-# enable HTTP server with metrics
-camel.server.enabled=true
-camel.server.metricsEnabled=true
+# enable HTTP management server with metrics
+camel.management.enabled=true
+camel.management.metricsEnabled=true
# turn on micrometer metrics
camel.metrics.enabled=true
diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportBaseCommand.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportBaseCommand.java
index 3b34417f19b..a98b709447c 100644
--- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportBaseCommand.java
+++ b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportBaseCommand.java
@@ -565,15 +565,18 @@ public abstract class ExportBaseCommand extends CamelCommand {
}
// automatic add needed dependencies when dev-console is enabled
if ("true".equalsIgnoreCase(prop.getProperty("camel.main.devConsoleEnabled"))
+ || "true".equalsIgnoreCase(prop.getProperty("camel.management.devConsoleEnabled"))
|| "true".equalsIgnoreCase(prop.getProperty("camel.server.devConsoleEnabled"))) {
answer.add("camel:console");
answer.add("camel:management");
}
// automatic add needed dependencies when main server enabled plugins
- if ("true".equalsIgnoreCase(prop.getProperty("camel.server.jolokiaEnabled"))) {
+ if ("true".equalsIgnoreCase(prop.getProperty("camel.management.jolokiaEnabled"))
+ || "true".equalsIgnoreCase(prop.getProperty("camel.server.jolokiaEnabled"))) {
answer.add("camel:platform-http-jolokia");
}
- if ("true".equalsIgnoreCase(prop.getProperty("camel.server.metricsEnabled"))) {
+ if ("true".equalsIgnoreCase(prop.getProperty("camel.management.metricsEnabled"))
+ || "true".equalsIgnoreCase(prop.getProperty("camel.server.metricsEnabled"))) {
answer.add("camel:micrometer-prometheus");
}
}
diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportCamelMain.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportCamelMain.java
index d6b53e17bbd..8688b871ae9 100644
--- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportCamelMain.java
+++ b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportCamelMain.java
@@ -133,7 +133,13 @@ class ExportCamelMain extends Export {
prop.put("camel.server.port", port);
}
if (!prop.containsKey("camel.server.health-check-enabled")) {
- prop.put("camel.server.health-check-enabled", "true");
+ if (VersionHelper.isGE(camelVersion, "4.14.0")) {
+ prop.put("camel.management.enabled", "true");
+ prop.put("camel.management.health-check-enabled", "true");
+ } else {
+ // old option name for Camel 4.13 and older
+ prop.put("camel.server.health-check-enabled", "true");
+ }
}
}
port = httpManagementPort(settings);
@@ -356,7 +362,9 @@ class ExportCamelMain extends Export {
Properties prop = new CamelCaseOrderedProperties();
RuntimeUtil.loadProperties(prop, profile);
// if metrics is defined then include camel-micrometer-prometheus for camel-main runtime
- if (prop.getProperty("camel.metrics.enabled") != null || prop.getProperty("camel.server.metricsEnabled") != null) {
+ if (prop.getProperty("camel.metrics.enabled") != null
+ || prop.getProperty("camel.management.metricsEnabled") != null
+ || prop.getProperty("camel.server.metricsEnabled") != null) {
answer.add("mvn:org.apache.camel:camel-micrometer-prometheus");
}
}
diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportQuarkus.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportQuarkus.java
index a01e55153db..8629174a251 100644
--- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportQuarkus.java
+++ b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportQuarkus.java
@@ -385,8 +385,8 @@ class ExportQuarkus extends Export {
@Override
protected String applicationPropertyLine(String key, String value) {
- if (key.startsWith("camel.server.")) {
- // skip "camel.server." as this is for camel-main only
+ if (key.startsWith("camel.server.") || key.startsWith("camel.management.")) {
+ // skip "camel.server." or "camel.management." as this is for camel-main only
return null;
}
// quarkus use dash cased properties and lets turn camel into dash as well (skip hawtio)
diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportSpringBoot.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportSpringBoot.java
index 1fb0f22a166..6dbc75a1b58 100644
--- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportSpringBoot.java
+++ b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportSpringBoot.java
@@ -399,8 +399,8 @@ class ExportSpringBoot extends Export {
@Override
protected String applicationPropertyLine(String key, String value) {
- if (key.startsWith("camel.server.")) {
- // skip "camel.server." as this is for camel-main only
+ if (key.startsWith("camel.server.") || key.startsWith("camel.management.")) {
+ // skip "camel.server." or "camel.management." as this is for camel-main only
return null;
}
boolean camel44orOlder = camelSpringBootVersion != null && VersionHelper.isLE("4.4.0", camelSpringBootVersion);
(camel) 14/15: CAMEL-22285: platform-http-main - Dev consoles should be registered as management endpoints
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch man
in repository https://gitbox.apache.org/repos/asf/camel.git
commit e17268f78f957388162b0ef0fab217027bf3ac63
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Jul 29 20:23:21 2025 +0200
CAMEL-22285: platform-http-main - Dev consoles should be registered as management endpoints
---
.../camel/component/micrometer/prometheus/MicrometerPrometheus.java | 4 ++--
.../camel/component/platform/http/main/ManagementHttpServer.java | 2 +-
.../org/apache/camel/dsl/jbang/it/MetricsObservabilityITCase.java | 4 ++--
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/components/camel-micrometer-prometheus/src/main/java/org/apache/camel/component/micrometer/prometheus/MicrometerPrometheus.java b/components/camel-micrometer-prometheus/src/main/java/org/apache/camel/component/micrometer/prometheus/MicrometerPrometheus.java
index c50402fd22a..602ad0bfbed 100644
--- a/components/camel-micrometer-prometheus/src/main/java/org/apache/camel/component/micrometer/prometheus/MicrometerPrometheus.java
+++ b/components/camel-micrometer-prometheus/src/main/java/org/apache/camel/component/micrometer/prometheus/MicrometerPrometheus.java
@@ -108,8 +108,8 @@ public class MicrometerPrometheus extends ServiceSupport implements CamelMetrics
private String textFormatVersion = "0.0.4";
@Metadata
private String binders;
- @Metadata(defaultValue = "/q/metrics")
- private String path = "/q/metrics";
+ @Metadata(defaultValue = "/observe/metrics")
+ private String path = "/observe/metrics";
@Override
public CamelContext getCamelContext() {
diff --git a/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/ManagementHttpServer.java b/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/ManagementHttpServer.java
index a09f4a56227..700db1c1cb7 100644
--- a/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/ManagementHttpServer.java
+++ b/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/ManagementHttpServer.java
@@ -249,7 +249,7 @@ public class ManagementHttpServer extends ServiceSupport implements CamelContext
}
/**
- * Whether metrics is enabled (q/metrics)
+ * Whether metrics is enabled (observe/metrics)
*/
public void setMetricsEnabled(boolean metricsEnabled) {
this.metricsEnabled = metricsEnabled;
diff --git a/dsl/camel-jbang/camel-jbang-it/src/test/java/org/apache/camel/dsl/jbang/it/MetricsObservabilityITCase.java b/dsl/camel-jbang/camel-jbang-it/src/test/java/org/apache/camel/dsl/jbang/it/MetricsObservabilityITCase.java
index d8720080d1a..12f5e6fb564 100644
--- a/dsl/camel-jbang/camel-jbang-it/src/test/java/org/apache/camel/dsl/jbang/it/MetricsObservabilityITCase.java
+++ b/dsl/camel-jbang/camel-jbang-it/src/test/java/org/apache/camel/dsl/jbang/it/MetricsObservabilityITCase.java
@@ -28,9 +28,9 @@ public class MetricsObservabilityITCase extends JBangTestSupport {
public void metricsTest() throws IOException {
copyResourceInDataFolder(TestResources.SERVER_ROUTE);
executeBackground(String.format("run %s/server.yaml --metrics", mountPoint()));
- checkLogContains("http://0.0.0.0:8080/q/metrics");
+ checkLogContains("http://0.0.0.0:8080/observe/metrics");
Assertions.assertThat(
- execInHost(String.format("curl http://localhost:%s/q/metrics", containerService.getDevConsolePort())))
+ execInHost(String.format("curl http://localhost:%s/observe/metrics", containerService.getDevConsolePort())))
.as("server should list metrics")
.contains("# HELP camel_exchanges_total Total number of processed exchanges");
}
(camel) 13/15: CAMEL-22285: platform-http-main - Dev consoles should be registered as management endpoints
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch man
in repository https://gitbox.apache.org/repos/asf/camel.git
commit e02bfadeb591fc511e3b060384075ca618434b83
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Jul 29 20:17:41 2025 +0200
CAMEL-22285: platform-http-main - Dev consoles should be registered as management endpoints
---
.../platform/http/vertx/VertxPlatformHttpServer.java | 2 +-
.../jbang/core/commands/kubernetes/KubernetesExportTest.java | 11 +++++++----
2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/components/camel-platform-http-vertx/src/main/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpServer.java b/components/camel-platform-http-vertx/src/main/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpServer.java
index 99ebf8502ae..e670c03c656 100644
--- a/components/camel-platform-http-vertx/src/main/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpServer.java
+++ b/components/camel-platform-http-vertx/src/main/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpServer.java
@@ -307,7 +307,7 @@ public class VertxPlatformHttpServer extends ServiceSupport implements CamelCont
throw new RuntimeException(result.cause());
}
- LOGGER.info("Vert.x stopped");
+ LOGGER.debug("Vert.x stopped");
} finally {
latch.countDown();
}
diff --git a/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/test/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/KubernetesExportTest.java b/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/test/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/KubernetesExportTest.java
index c3748cf77f0..5e8b2e3556f 100644
--- a/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/test/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/KubernetesExportTest.java
+++ b/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/test/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/KubernetesExportTest.java
@@ -71,15 +71,18 @@ class KubernetesExportTest extends KubernetesExportBaseTest {
Assertions.assertNull(props.get("jkube.container-image.registry"));
Assertions.assertNull(props.get("jkube.container-image.platforms"));
+ Properties applicationProperties = getApplicationProperties(workingDir);
+
if (RuntimeType.quarkus == RuntimeType.fromValue(rt.runtime())) {
Assertions.assertEquals("9876", props.get("quarkus.management.port"));
+ Assertions.assertEquals("9876", applicationProperties.get("quarkus.management.port"));
Assertions.assertEquals("/observe/health", props.get("quarkus.smallrye-health.root-path"));
} else if (RuntimeType.springBoot == RuntimeType.fromValue(rt.runtime())) {
- Assertions.assertEquals("9876", props.get("management.server.port"));
- Assertions.assertEquals("/observe", props.get("management.endpoints.web.base-path"));
- Assertions.assertEquals("true", props.get("management.health.probes.enabled"));
+ Assertions.assertEquals("9876", applicationProperties.get("management.server.port"));
+ Assertions.assertEquals("/observe", applicationProperties.get("management.endpoints.web.base-path"));
+ Assertions.assertEquals("true", applicationProperties.get("management.health.probes.enabled"));
} else if (RuntimeType.main == RuntimeType.fromValue(rt.runtime())) {
- Assertions.assertEquals("9876", props.get("camel.management.port"));
+ Assertions.assertEquals("9876", applicationProperties.get("camel.management.port"));
}
}
(camel) 07/15: CAMEL-22285: platform-http-main - Dev consoles should be registered as management endpoints
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch man
in repository https://gitbox.apache.org/repos/asf/camel.git
commit ab6ee2e99bf2f8c0e370631c91f28cf18500d79e
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Jul 29 17:01:38 2025 +0200
CAMEL-22285: platform-http-main - Dev consoles should be registered as management endpoints
---
.../main/camel-main-configuration-metadata.json | 11 ++++----
.../src/main/docs/observability-services.adoc | 4 +--
.../resources/observability-services.properties | 7 ------
.../src/main/docs/platform-http-jolokia.adoc | 19 +++++++-------
.../src/main/docs/platform-http-main.adoc | 17 +++++++------
.../http/main/DefaultMainHttpServerFactory.java | 1 +
.../platform/http/main/ManagementHttpServer.java | 14 +++++++++--
...entServerConfigurationPropertiesConfigurer.java | 7 ++++++
.../camel-main-configuration-metadata.json | 11 ++++----
core/camel-main/src/main/docs/main.adoc | 13 +++++-----
...ttpManagementServerConfigurationProperties.java | 29 +++++++++++++++++++---
.../camel/main/MetricsConfigurationProperties.java | 4 +--
.../modules/ROOT/pages/camel-jbang.adoc | 14 +++++------
.../camel/main/download/MainHttpServerFactory.java | 9 ++++---
14 files changed, 99 insertions(+), 61 deletions(-)
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/camel-main-configuration-metadata.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/camel-main-configuration-metadata.json
index 66eff52bf6b..8d0e74e0888 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/camel-main-configuration-metadata.json
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/camel-main-configuration-metadata.json
@@ -197,16 +197,17 @@
{ "name": "camel.management.devConsoleEnabled", "description": "Whether to enable developer console (not intended for production use). Dev console must also be enabled on CamelContext. For example by setting camel.context.dev-console=true in application.properties, or via code camelContext.setDevConsole(true); If enabled then you can access a basic developer console on context-path: \/q\/dev.", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": [...]
{ "name": "camel.management.downloadEnabled", "description": "Whether to enable file download via HTTP. This makes it possible to browse and download resource source files such as Camel XML or YAML routes. Only enable this for development, troubleshooting or special situations for management and monitoring.", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
{ "name": "camel.management.enabled", "description": "Whether embedded HTTP server is enabled. By default, the server is not enabled.", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
- { "name": "camel.management.healthCheckEnabled", "description": "Whether to enable health-check console. If enabled then you can access health-check status on context-path: \/q\/health (default)", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
+ { "name": "camel.management.healthCheckEnabled", "description": "Whether to enable health-check console. If enabled then you can access health-check status on context-path: \/observe\/health", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
{ "name": "camel.management.healthPath", "description": "The path endpoint used to expose the health status", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "string", "javaType": "java.lang.String", "defaultValue": "\/observe\/health" },
{ "name": "camel.management.host", "description": "Hostname to use for binding embedded HTTP server", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "string", "javaType": "java.lang.String", "defaultValue": "0.0.0.0" },
- { "name": "camel.management.infoEnabled", "description": "Whether to enable info console. If enabled then you can see some basic Camel information at \/q\/info", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
- { "name": "camel.management.jolokiaEnabled", "description": "Whether to enable jolokia. If enabled then you can access jolokia api on context-path: \/q\/jolokia", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
+ { "name": "camel.management.infoEnabled", "description": "Whether to enable info console. If enabled then you can see some basic Camel information at \/observe\/info", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
+ { "name": "camel.management.infoPath", "description": "The path endpoint used to expose the info status", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "string", "javaType": "java.lang.String", "defaultValue": "\/observe\/info" },
+ { "name": "camel.management.jolokiaEnabled", "description": "Whether to enable jolokia. If enabled then you can access jolokia api on context-path: \/observe\/jolokia", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
{ "name": "camel.management.jolokiaPath", "description": "The path endpoint used to expose the jolokia data.", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "string", "javaType": "java.lang.String", "defaultValue": "\/observe\/jolokia" },
{ "name": "camel.management.jwtKeystorePassword", "description": "Password from the keystore used for JWT tokens validation.", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "string", "javaType": "java.lang.String" },
{ "name": "camel.management.jwtKeystorePath", "description": "Path to the keystore file used for JWT tokens validation.", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "string", "javaType": "java.lang.String" },
{ "name": "camel.management.jwtKeystoreType", "description": "Type of the keystore used for JWT tokens validation (jks, pkcs12, etc.).", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "string", "javaType": "java.lang.String" },
- { "name": "camel.management.metricsEnabled", "description": "Whether to enable metrics. If enabled then you can access metrics on context-path: \/q\/metrics (default)", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
+ { "name": "camel.management.metricsEnabled", "description": "Whether to enable metrics. If enabled then you can access metrics on context-path: \/observe\/metrics", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
{ "name": "camel.management.path", "description": "Context-path to use for embedded HTTP server", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "string", "javaType": "java.lang.String", "defaultValue": "\/" },
{ "name": "camel.management.port", "description": "Port to use for binding embedded HTTP server", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "integer", "javaType": "int", "defaultValue": 8080 },
{ "name": "camel.management.sendEnabled", "description": "Whether to enable sending messages to Camel via HTTP. This makes it possible to use Camel to send messages to Camel endpoint URIs via HTTP.", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
@@ -223,7 +224,7 @@
{ "name": "camel.metrics.enableRouteEventNotifier", "description": "Set whether to enable the MicrometerRouteEventNotifier for capturing metrics on the total number of routes and total number of routes running.", "sourceType": "org.apache.camel.main.MetricsConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": true },
{ "name": "camel.metrics.enableRoutePolicy", "description": "Set whether to enable the MicrometerRoutePolicyFactory for capturing metrics on route processing times.", "sourceType": "org.apache.camel.main.MetricsConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": true },
{ "name": "camel.metrics.namingStrategy", "description": "Controls the name style to use for metrics. Default = uses micrometer naming convention. Legacy = uses the classic naming style (camelCase)", "sourceType": "org.apache.camel.main.MetricsConfigurationProperties", "type": "string", "javaType": "java.lang.String", "defaultValue": "default", "enum": [ "default", "legacy" ] },
- { "name": "camel.metrics.path", "description": "The path endpoint used to expose the metrics.", "sourceType": "org.apache.camel.main.MetricsConfigurationProperties", "type": "string", "javaType": "java.lang.String", "defaultValue": "\/q\/metrics" },
+ { "name": "camel.metrics.path", "description": "The path endpoint used to expose the metrics.", "sourceType": "org.apache.camel.main.MetricsConfigurationProperties", "type": "string", "javaType": "java.lang.String", "defaultValue": "\/observe\/metrics" },
{ "name": "camel.metrics.routePolicyLevel", "description": "Sets the level of information to capture. all = both context and routes.", "sourceType": "org.apache.camel.main.MetricsConfigurationProperties", "type": "string", "javaType": "java.lang.String", "defaultValue": "all", "enum": [ "all", "route", "context" ] },
{ "name": "camel.metrics.skipCamelInfo", "description": "Skip the evaluation of app.info metric which contains runtime provider information (default, false).", "sourceType": "org.apache.camel.main.MetricsConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": false },
{ "name": "camel.metrics.textFormatVersion", "description": "The text-format version to use with Prometheus scraping. 0.0.4 = text\/plain; version=0.0.4; charset=utf-8 1.0.0 = application\/openmetrics-text; version=1.0.0; charset=utf-8", "sourceType": "org.apache.camel.main.MetricsConfigurationProperties", "type": "string", "javaType": "java.lang.String", "defaultValue": "0.0.4", "enum": [ "0.0.4", "1.0.0" ] },
diff --git a/components/camel-observability-services/src/main/docs/observability-services.adoc b/components/camel-observability-services/src/main/docs/observability-services.adoc
index 04613c5249d..ba73bee1faa 100644
--- a/components/camel-observability-services/src/main/docs/observability-services.adoc
+++ b/components/camel-observability-services/src/main/docs/observability-services.adoc
@@ -119,9 +119,9 @@ In this case, it is recommended the usage of a JSR 160 compatible Java agent.
==== JMX Agent configuration
-When dealing with JMX,
-you may want
+When dealing with JMX, you may want
to expose the information available via HTTP(S) protocol which would make JMX more suitable to cloud-based development.
A possible way to expose the information is to use a JSR 160 compatible Java agent,
whose goal is to interact as an adapter interface towards JMX, exposing an HTTP-based service instead.
+
Follow the instructions provided in xref:manual::jmx.adoc#_how_to_use_a_java_agent[JMX Java Agent configuration].
diff --git a/components/camel-observability-services/src/main/resources/observability-services.properties b/components/camel-observability-services/src/main/resources/observability-services.properties
index 75315d5e351..614b57a73b0 100644
--- a/components/camel-observability-services/src/main/resources/observability-services.properties
+++ b/components/camel-observability-services/src/main/resources/observability-services.properties
@@ -15,13 +15,6 @@
## limitations under the License.
## ---------------------------------------------------------------------------
-# Enable server
-# Deprecated: camel.server properties should be removed in future releases
-camel.server.enabled=true
-camel.server.metricsEnabled=true
-camel.server.healthCheckEnabled=true
-camel.server.healthPath=/observe/health
-
# Enable management server
camel.management.enabled=true
camel.management.metricsEnabled=true
diff --git a/components/camel-platform-http-jolokia/src/main/docs/platform-http-jolokia.adoc b/components/camel-platform-http-jolokia/src/main/docs/platform-http-jolokia.adoc
index bec7528f151..40065b2cade 100644
--- a/components/camel-platform-http-jolokia/src/main/docs/platform-http-jolokia.adoc
+++ b/components/camel-platform-http-jolokia/src/main/docs/platform-http-jolokia.adoc
@@ -10,21 +10,21 @@
*Since Camel {since}*
The Platform HTTP Jolokia component is used for Camel standalone to expose Jolokia over HTTP
-using the embedded HTTP server.
+using the embedded management HTTP server.
Jolokia can be enabled as follows in `application.properties`:
[source,properties]
----
-camel.server.enabled = true
-camel.server.jolokiaEnabled = true
+camel.management.enabled = true
+camel.management.jolokiaEnabled = true
----
-After the application is started, you can query the Jolokia endpoint (default `/q/jolokia`) as in this example:
-
-```
-$ curl http://localhost:8080/q/jolokia/list/org.apache.camel | jq
+After the application is started, you can query the Jolokia endpoint (default `/observe/jolokia`) as in this example:
+[source,bash]
+====
+$ curl http://localhost:8080/observe/jolokia/list/org.apache.camel | jq
{
"request": {
"path": "org.apache.camel",
@@ -38,12 +38,11 @@ $ curl http://localhost:8080/q/jolokia/list/org.apache.camel | jq
"ret": "java.lang.String",
"desc": "EndpointUri"
},
-...
-```
+====
== How to use it
-This components acts as a Jolokia agent exposing HTTP endpoints to access JMX services. It looks for default restrictor policies located in `classpath:/jolokia-access.xml`, allowing by default access to all MBeans if no policy is found.
+This component acts as a Jolokia agent exposing HTTP endpoints to access JMX services. It looks for default restrictor policies located in `classpath:/jolokia-access.xml`, allowing by default access to all MBeans if no policy is found.
WARNING: this may be exposing sensitive information, make sure to protect the access to the endpoints accurately.
diff --git a/components/camel-platform-http-main/src/main/docs/platform-http-main.adoc b/components/camel-platform-http-main/src/main/docs/platform-http-main.adoc
index a026d5b9b5b..2992696a0b3 100644
--- a/components/camel-platform-http-main/src/main/docs/platform-http-main.adoc
+++ b/components/camel-platform-http-main/src/main/docs/platform-http-main.adoc
@@ -25,21 +25,22 @@ Then, the platform http component should auto-detect this.
== Uploading and downloading files
-The embedded HTTP server comes with a set of features out of the box, that can be enabled.
+The embedded HTTP server comes with a set of features out of the box (management, development and user services),
+that can be enabled.
These features are as follows:
-- `/q/info` - Report basic information about Camel
-- `/dev/console` - Developer console that provides a lot of statistics and information
-- `/q/health (default)` - Health checks
-- `/q/jolokia` - To use Jolokia to expose JMX over HTTP REST
-- `/q/metrics (default)` - To provide otel metrics in prometheus format
+- `/` - Serving static content such as html, javascript, css, and images to make it easy to embed very small web applications.
+- `/observe/info` - Report basic information about Camel
+- `/observe/health` - Health checks
+- `/observe/jolokia` - To use Jolokia to expose JMX over HTTP REST
+- `/observe/metrics` - To provide OTEL metrics in prometheus format
+- `/q/dev` - Developer console that provides a lot of statistics and information
- `/q/upload` - Uploading source files, to allow hot reloading.
- `/q/download` - Downloading source files, to allow inspecting
- `/q/send` - Sending messages to the Camel application via HTTP
-- `/` - Serving static content such as html, javascript, css, and images to make it easy to embed very small web applications.
-You configure these features in the `application.properties` file using the `camel.server.xxx` options.
+You configure these features in the `application.properties` file using the `camel.server.xxx` and `camel.management.xxx` options.
== See More
diff --git a/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/DefaultMainHttpServerFactory.java b/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/DefaultMainHttpServerFactory.java
index 0ae2a43f927..c995da8a065 100644
--- a/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/DefaultMainHttpServerFactory.java
+++ b/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/DefaultMainHttpServerFactory.java
@@ -93,6 +93,7 @@ public class DefaultMainHttpServerFactory implements CamelContextAware, MainHttp
server.setDevConsoleEnabled(configuration.isDevConsoleEnabled());
server.setHealthCheckEnabled(configuration.isHealthCheckEnabled());
server.setHealthPath(configuration.getHealthPath());
+ server.setInfoPath(configuration.getInfoPath());
server.setJolokiaEnabled(configuration.isJolokiaEnabled());
server.setJolokiaPath(configuration.getJolokiaPath());
server.setMetricsEnabled(configuration.isMetricsEnabled());
diff --git a/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/ManagementHttpServer.java b/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/ManagementHttpServer.java
index a4dc1104dbd..a09f4a56227 100644
--- a/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/ManagementHttpServer.java
+++ b/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/ManagementHttpServer.java
@@ -121,6 +121,7 @@ public class ManagementHttpServer extends ServiceSupport implements CamelContext
private boolean healthCheckEnabled;
private boolean jolokiaEnabled;
private boolean metricsEnabled;
+ private String infoPath;
private String healthPath;
private String jolokiaPath;
private boolean uploadEnabled;
@@ -209,6 +210,15 @@ public class ManagementHttpServer extends ServiceSupport implements CamelContext
this.jolokiaEnabled = jolokiaEnabledEnabled;
}
+ @ManagedAttribute(description = "The context-path for serving info status")
+ public String getInfoPath() {
+ return infoPath;
+ }
+
+ public void setInfoPath(String infoPath) {
+ this.infoPath = infoPath;
+ }
+
@ManagedAttribute(description = "The context-path for serving health check status")
public String getHealthPath() {
return healthPath;
@@ -447,7 +457,7 @@ public class ManagementHttpServer extends ServiceSupport implements CamelContext
}
protected void setupInfo() {
- final Route info = router.route("/q/info");
+ final Route info = router.route(this.infoPath);
info.method(HttpMethod.GET);
info.produces("application/json");
@@ -563,7 +573,7 @@ public class ManagementHttpServer extends ServiceSupport implements CamelContext
// use blocking handler as the task can take longer time to complete
info.handler(new BlockingHandlerDecorator(handler, true));
- platformHttpComponent.addHttpManagementEndpoint("/q/info", "GET", null,
+ platformHttpComponent.addHttpManagementEndpoint(this.infoPath, "GET", null,
"application/json", null);
}
diff --git a/core/camel-main/src/generated/java/org/apache/camel/main/HttpManagementServerConfigurationPropertiesConfigurer.java b/core/camel-main/src/generated/java/org/apache/camel/main/HttpManagementServerConfigurationPropertiesConfigurer.java
index 97418f57cfa..069888b08fa 100644
--- a/core/camel-main/src/generated/java/org/apache/camel/main/HttpManagementServerConfigurationPropertiesConfigurer.java
+++ b/core/camel-main/src/generated/java/org/apache/camel/main/HttpManagementServerConfigurationPropertiesConfigurer.java
@@ -32,6 +32,7 @@ public class HttpManagementServerConfigurationPropertiesConfigurer extends org.a
map.put("HealthPath", java.lang.String.class);
map.put("Host", java.lang.String.class);
map.put("InfoEnabled", boolean.class);
+ map.put("InfoPath", java.lang.String.class);
map.put("JolokiaEnabled", boolean.class);
map.put("JolokiaPath", java.lang.String.class);
map.put("JwtKeystorePassword", java.lang.String.class);
@@ -69,6 +70,8 @@ public class HttpManagementServerConfigurationPropertiesConfigurer extends org.a
case "host": target.setHost(property(camelContext, java.lang.String.class, value)); return true;
case "infoenabled":
case "infoEnabled": target.setInfoEnabled(property(camelContext, boolean.class, value)); return true;
+ case "infopath":
+ case "infoPath": target.setInfoPath(property(camelContext, java.lang.String.class, value)); return true;
case "jolokiaenabled":
case "jolokiaEnabled": target.setJolokiaEnabled(property(camelContext, boolean.class, value)); return true;
case "jolokiapath":
@@ -121,6 +124,8 @@ public class HttpManagementServerConfigurationPropertiesConfigurer extends org.a
case "host": return java.lang.String.class;
case "infoenabled":
case "infoEnabled": return boolean.class;
+ case "infopath":
+ case "infoPath": return java.lang.String.class;
case "jolokiaenabled":
case "jolokiaEnabled": return boolean.class;
case "jolokiapath":
@@ -169,6 +174,8 @@ public class HttpManagementServerConfigurationPropertiesConfigurer extends org.a
case "host": return target.getHost();
case "infoenabled":
case "infoEnabled": return target.isInfoEnabled();
+ case "infopath":
+ case "infoPath": return target.getInfoPath();
case "jolokiaenabled":
case "jolokiaEnabled": return target.isJolokiaEnabled();
case "jolokiapath":
diff --git a/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json b/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json
index 66eff52bf6b..8d0e74e0888 100644
--- a/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json
+++ b/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json
@@ -197,16 +197,17 @@
{ "name": "camel.management.devConsoleEnabled", "description": "Whether to enable developer console (not intended for production use). Dev console must also be enabled on CamelContext. For example by setting camel.context.dev-console=true in application.properties, or via code camelContext.setDevConsole(true); If enabled then you can access a basic developer console on context-path: \/q\/dev.", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": [...]
{ "name": "camel.management.downloadEnabled", "description": "Whether to enable file download via HTTP. This makes it possible to browse and download resource source files such as Camel XML or YAML routes. Only enable this for development, troubleshooting or special situations for management and monitoring.", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
{ "name": "camel.management.enabled", "description": "Whether embedded HTTP server is enabled. By default, the server is not enabled.", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
- { "name": "camel.management.healthCheckEnabled", "description": "Whether to enable health-check console. If enabled then you can access health-check status on context-path: \/q\/health (default)", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
+ { "name": "camel.management.healthCheckEnabled", "description": "Whether to enable health-check console. If enabled then you can access health-check status on context-path: \/observe\/health", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
{ "name": "camel.management.healthPath", "description": "The path endpoint used to expose the health status", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "string", "javaType": "java.lang.String", "defaultValue": "\/observe\/health" },
{ "name": "camel.management.host", "description": "Hostname to use for binding embedded HTTP server", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "string", "javaType": "java.lang.String", "defaultValue": "0.0.0.0" },
- { "name": "camel.management.infoEnabled", "description": "Whether to enable info console. If enabled then you can see some basic Camel information at \/q\/info", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
- { "name": "camel.management.jolokiaEnabled", "description": "Whether to enable jolokia. If enabled then you can access jolokia api on context-path: \/q\/jolokia", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
+ { "name": "camel.management.infoEnabled", "description": "Whether to enable info console. If enabled then you can see some basic Camel information at \/observe\/info", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
+ { "name": "camel.management.infoPath", "description": "The path endpoint used to expose the info status", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "string", "javaType": "java.lang.String", "defaultValue": "\/observe\/info" },
+ { "name": "camel.management.jolokiaEnabled", "description": "Whether to enable jolokia. If enabled then you can access jolokia api on context-path: \/observe\/jolokia", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
{ "name": "camel.management.jolokiaPath", "description": "The path endpoint used to expose the jolokia data.", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "string", "javaType": "java.lang.String", "defaultValue": "\/observe\/jolokia" },
{ "name": "camel.management.jwtKeystorePassword", "description": "Password from the keystore used for JWT tokens validation.", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "string", "javaType": "java.lang.String" },
{ "name": "camel.management.jwtKeystorePath", "description": "Path to the keystore file used for JWT tokens validation.", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "string", "javaType": "java.lang.String" },
{ "name": "camel.management.jwtKeystoreType", "description": "Type of the keystore used for JWT tokens validation (jks, pkcs12, etc.).", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "string", "javaType": "java.lang.String" },
- { "name": "camel.management.metricsEnabled", "description": "Whether to enable metrics. If enabled then you can access metrics on context-path: \/q\/metrics (default)", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
+ { "name": "camel.management.metricsEnabled", "description": "Whether to enable metrics. If enabled then you can access metrics on context-path: \/observe\/metrics", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
{ "name": "camel.management.path", "description": "Context-path to use for embedded HTTP server", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "string", "javaType": "java.lang.String", "defaultValue": "\/" },
{ "name": "camel.management.port", "description": "Port to use for binding embedded HTTP server", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "integer", "javaType": "int", "defaultValue": 8080 },
{ "name": "camel.management.sendEnabled", "description": "Whether to enable sending messages to Camel via HTTP. This makes it possible to use Camel to send messages to Camel endpoint URIs via HTTP.", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
@@ -223,7 +224,7 @@
{ "name": "camel.metrics.enableRouteEventNotifier", "description": "Set whether to enable the MicrometerRouteEventNotifier for capturing metrics on the total number of routes and total number of routes running.", "sourceType": "org.apache.camel.main.MetricsConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": true },
{ "name": "camel.metrics.enableRoutePolicy", "description": "Set whether to enable the MicrometerRoutePolicyFactory for capturing metrics on route processing times.", "sourceType": "org.apache.camel.main.MetricsConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": true },
{ "name": "camel.metrics.namingStrategy", "description": "Controls the name style to use for metrics. Default = uses micrometer naming convention. Legacy = uses the classic naming style (camelCase)", "sourceType": "org.apache.camel.main.MetricsConfigurationProperties", "type": "string", "javaType": "java.lang.String", "defaultValue": "default", "enum": [ "default", "legacy" ] },
- { "name": "camel.metrics.path", "description": "The path endpoint used to expose the metrics.", "sourceType": "org.apache.camel.main.MetricsConfigurationProperties", "type": "string", "javaType": "java.lang.String", "defaultValue": "\/q\/metrics" },
+ { "name": "camel.metrics.path", "description": "The path endpoint used to expose the metrics.", "sourceType": "org.apache.camel.main.MetricsConfigurationProperties", "type": "string", "javaType": "java.lang.String", "defaultValue": "\/observe\/metrics" },
{ "name": "camel.metrics.routePolicyLevel", "description": "Sets the level of information to capture. all = both context and routes.", "sourceType": "org.apache.camel.main.MetricsConfigurationProperties", "type": "string", "javaType": "java.lang.String", "defaultValue": "all", "enum": [ "all", "route", "context" ] },
{ "name": "camel.metrics.skipCamelInfo", "description": "Skip the evaluation of app.info metric which contains runtime provider information (default, false).", "sourceType": "org.apache.camel.main.MetricsConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": false },
{ "name": "camel.metrics.textFormatVersion", "description": "The text-format version to use with Prometheus scraping. 0.0.4 = text\/plain; version=0.0.4; charset=utf-8 1.0.0 = application\/openmetrics-text; version=1.0.0; charset=utf-8", "sourceType": "org.apache.camel.main.MetricsConfigurationProperties", "type": "string", "javaType": "java.lang.String", "defaultValue": "0.0.4", "enum": [ "0.0.4", "1.0.0" ] },
diff --git a/core/camel-main/src/main/docs/main.adoc b/core/camel-main/src/main/docs/main.adoc
index fdeffb691d2..f61092f5ab7 100644
--- a/core/camel-main/src/main/docs/main.adoc
+++ b/core/camel-main/src/main/docs/main.adoc
@@ -215,7 +215,7 @@ The camel.server supports 17 options, which are listed below.
=== Camel Embedded HTTP management Server (only for standalone; not Spring Boot or Quarkus) configurations
-The camel.management supports 22 options, which are listed below.
+The camel.management supports 23 options, which are listed below.
[width="100%",cols="2,5,^1,2",options="header"]
|===
@@ -226,16 +226,17 @@ The camel.management supports 22 options, which are listed below.
| *camel.management.devConsole{zwsp}Enabled* | Whether to enable developer console (not intended for production use). Dev console must also be enabled on CamelContext. For example by setting camel.context.dev-console=true in application.properties, or via code camelContext.setDevConsole(true); If enabled then you can access a basic developer console on context-path: /q/dev. | false | boolean
| *camel.management.download{zwsp}Enabled* | Whether to enable file download via HTTP. This makes it possible to browse and download resource source files such as Camel XML or YAML routes. Only enable this for development, troubleshooting or special situations for management and monitoring. | false | boolean
| *camel.management.enabled* | Whether embedded HTTP server is enabled. By default, the server is not enabled. | false | boolean
-| *camel.management.healthCheck{zwsp}Enabled* | Whether to enable health-check console. If enabled then you can access health-check status on context-path: /q/health (default) | false | boolean
+| *camel.management.healthCheck{zwsp}Enabled* | Whether to enable health-check console. If enabled then you can access health-check status on context-path: /observe/health | false | boolean
| *camel.management.healthPath* | The path endpoint used to expose the health status | /observe/health | String
| *camel.management.host* | Hostname to use for binding embedded HTTP server | 0.0.0.0 | String
-| *camel.management.infoEnabled* | Whether to enable info console. If enabled then you can see some basic Camel information at /q/info | false | boolean
-| *camel.management.jolokia{zwsp}Enabled* | Whether to enable jolokia. If enabled then you can access jolokia api on context-path: /q/jolokia | false | boolean
+| *camel.management.infoEnabled* | Whether to enable info console. If enabled then you can see some basic Camel information at /observe/info | false | boolean
+| *camel.management.infoPath* | The path endpoint used to expose the info status | /observe/info | String
+| *camel.management.jolokia{zwsp}Enabled* | Whether to enable jolokia. If enabled then you can access jolokia api on context-path: /observe/jolokia | false | boolean
| *camel.management.jolokiaPath* | The path endpoint used to expose the jolokia data. | /observe/jolokia | String
| *camel.management.jwtKeystore{zwsp}Password* | Password from the keystore used for JWT tokens validation. | | String
| *camel.management.jwtKeystore{zwsp}Path* | Path to the keystore file used for JWT tokens validation. | | String
| *camel.management.jwtKeystore{zwsp}Type* | Type of the keystore used for JWT tokens validation (jks, pkcs12, etc.). | | String
-| *camel.management.metrics{zwsp}Enabled* | Whether to enable metrics. If enabled then you can access metrics on context-path: /q/metrics (default) | false | boolean
+| *camel.management.metrics{zwsp}Enabled* | Whether to enable metrics. If enabled then you can access metrics on context-path: /observe/metrics | false | boolean
| *camel.management.path* | Context-path to use for embedded HTTP server | / | String
| *camel.management.port* | Port to use for binding embedded HTTP server | 8080 | int
| *camel.management.sendEnabled* | Whether to enable sending messages to Camel via HTTP. This makes it possible to use Camel to send messages to Camel endpoint URIs via HTTP. | false | boolean
@@ -574,7 +575,7 @@ The camel.metrics supports 14 options, which are listed below.
| *camel.metrics.enableRouteEvent{zwsp}Notifier* | Set whether to enable the MicrometerRouteEventNotifier for capturing metrics on the total number of routes and total number of routes running. | true | boolean
| *camel.metrics.enableRoute{zwsp}Policy* | Set whether to enable the MicrometerRoutePolicyFactory for capturing metrics on route processing times. | true | boolean
| *camel.metrics.namingStrategy* | Controls the name style to use for metrics. Default = uses micrometer naming convention. Legacy = uses the classic naming style (camelCase) | default | String
-| *camel.metrics.path* | The path endpoint used to expose the metrics. | /q/metrics | String
+| *camel.metrics.path* | The path endpoint used to expose the metrics. | /observe/metrics | String
| *camel.metrics.routePolicyLevel* | Sets the level of information to capture. all = both context and routes. | all | String
| *camel.metrics.skipCamelInfo* | Skip the evaluation of app.info metric which contains runtime provider information (default, false). | false | boolean
| *camel.metrics.textFormat{zwsp}Version* | The text-format version to use with Prometheus scraping. 0.0.4 = text/plain; version=0.0.4; charset=utf-8 1.0.0 = application/openmetrics-text; version=1.0.0; charset=utf-8 | 0.0.4 | String
diff --git a/core/camel-main/src/main/java/org/apache/camel/main/HttpManagementServerConfigurationProperties.java b/core/camel-main/src/main/java/org/apache/camel/main/HttpManagementServerConfigurationProperties.java
index a18d01e078c..ef78f494f09 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/HttpManagementServerConfigurationProperties.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/HttpManagementServerConfigurationProperties.java
@@ -36,6 +36,8 @@ public class HttpManagementServerConfigurationProperties implements BootstrapClo
private int port = 8080;
@Metadata(defaultValue = "/")
private String path = "/";
+ @Metadata(defaultValue = "/observe/info")
+ private String infoPath = "/observe/info";
@Metadata(defaultValue = "/observe/health")
private String healthPath = "/observe/health";
@Metadata(defaultValue = "/observe/jolokia")
@@ -139,7 +141,7 @@ public class HttpManagementServerConfigurationProperties implements BootstrapClo
}
/**
- * Whether to enable info console. If enabled then you can see some basic Camel information at /q/info
+ * Whether to enable info console. If enabled then you can see some basic Camel information at /observe/info
*/
public void setInfoEnabled(boolean infoEnabled) {
this.infoEnabled = infoEnabled;
@@ -165,7 +167,7 @@ public class HttpManagementServerConfigurationProperties implements BootstrapClo
/**
* Whether to enable health-check console. If enabled then you can access health-check status on context-path:
- * /q/health (default)
+ * /observe/health
*/
public void setHealthCheckEnabled(boolean healthCheckEnabled) {
this.healthCheckEnabled = healthCheckEnabled;
@@ -176,7 +178,7 @@ public class HttpManagementServerConfigurationProperties implements BootstrapClo
}
/**
- * Whether to enable jolokia. If enabled then you can access jolokia api on context-path: /q/jolokia
+ * Whether to enable jolokia. If enabled then you can access jolokia api on context-path: /observe/jolokia
*/
public void setJolokiaEnabled(boolean jolokiaEnabled) {
this.jolokiaEnabled = jolokiaEnabled;
@@ -187,12 +189,23 @@ public class HttpManagementServerConfigurationProperties implements BootstrapClo
}
/**
- * Whether to enable metrics. If enabled then you can access metrics on context-path: /q/metrics (default)
+ * Whether to enable metrics. If enabled then you can access metrics on context-path: /observe/metrics
*/
public void setMetricsEnabled(boolean metricsEnabled) {
this.metricsEnabled = metricsEnabled;
}
+ public String getInfoPath() {
+ return infoPath;
+ }
+
+ /**
+ * The path endpoint used to expose the info status
+ */
+ public void setInfoPath(String infoPath) {
+ this.infoPath = infoPath;
+ }
+
public String getHealthPath() {
return healthPath;
}
@@ -504,6 +517,14 @@ public class HttpManagementServerConfigurationProperties implements BootstrapClo
return this;
}
+ /**
+ * The path endpoint used to expose the info status
+ */
+ public HttpManagementServerConfigurationProperties withInfoPath(String infoPath) {
+ this.infoPath = infoPath;
+ return this;
+ }
+
/**
* The path endpoint used to expose the health status
*/
diff --git a/core/camel-main/src/main/java/org/apache/camel/main/MetricsConfigurationProperties.java b/core/camel-main/src/main/java/org/apache/camel/main/MetricsConfigurationProperties.java
index d2590b431ea..b4241cec676 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/MetricsConfigurationProperties.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/MetricsConfigurationProperties.java
@@ -52,8 +52,8 @@ public class MetricsConfigurationProperties implements BootstrapCloseable {
private String textFormatVersion = "0.0.4";
@Metadata
private String binders;
- @Metadata(defaultValue = "/q/metrics")
- private String path = "/q/metrics";
+ @Metadata(defaultValue = "/observe/metrics")
+ private String path = "/observe/metrics";
public MetricsConfigurationProperties(MainConfigurationProperties parent) {
this.parent = parent;
diff --git a/docs/user-manual/modules/ROOT/pages/camel-jbang.adoc b/docs/user-manual/modules/ROOT/pages/camel-jbang.adoc
index ecb691af98b..d9b6c2dd77d 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-jbang.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-jbang.adoc
@@ -2018,9 +2018,9 @@ You simply either run with `--metrics` option, or enable and have more control o
[source,properties]
----
-# enable HTTP server with metrics
-camel.server.enabled=true
-camel.server.metricsEnabled=true
+# enable HTTP management server with metrics
+camel.management.enabled=true
+camel.management.metricsEnabled=true
# turn on micrometer metrics
camel.metrics.enabled=true
@@ -2030,7 +2030,7 @@ camel.metrics.enableMessageHistory=true
camel.metrics.binders=processor,jvm-info,file-descriptor
----
-Then you can access metrics from the web browser at: http://localhost:8080/q/metrics[http://localhost:8080/q/metrics]
+Then you can access metrics from the web browser at: http://localhost:8080/observe/metrics[http://localhost:8080/observe/metrics]
You can also see metrics from the CLI as shown below:
@@ -3920,13 +3920,13 @@ The follow options related to _exporting_, can be configured in `application.pro
| Developer console at /q/dev on local HTTP server (port 8080 by default) when running standalone Camel
|`camel.jbang.info`
-| Info console at /q/info on local HTTP server (port 8080 by default) when running standalone Camel
+| Info console at /observe/info on local HTTP server (port 8080 by default) when running standalone Camel
|`camel.jbang.health`
-| Health check at /q/health on local HTTP server (port 8080 by default) when running standalone Camel
+| Health check at /observe/health on local HTTP server (port 8080 by default) when running standalone Camel
|`camel.jbang.metrics`
-| Metrics (Micrometer and Prometheus) at /q/metrics on local HTTP server (port 8080 by default) when running standalone Camel
+| Metrics (Micrometer and Prometheus) at /observe/metrics on local HTTP server (port 8080 by default) when running standalone Camel
|`camel.jbang.open-api`
| File name of open-api spec file (JSON or YAML) that are used when using `--open-api` to generate routes from the swagger/openapi API spec file.
diff --git a/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/download/MainHttpServerFactory.java b/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/download/MainHttpServerFactory.java
index 7f76d5722c0..6907d8e62bf 100644
--- a/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/download/MainHttpServerFactory.java
+++ b/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/download/MainHttpServerFactory.java
@@ -19,6 +19,7 @@ package org.apache.camel.main.download;
import org.apache.camel.CamelContext;
import org.apache.camel.Service;
import org.apache.camel.component.platform.http.main.MainHttpServer;
+import org.apache.camel.component.platform.http.main.ManagementHttpServer;
import org.apache.camel.main.HttpServerConfigurationProperties;
import org.apache.camel.main.MainConstants;
import org.apache.camel.main.util.CamelJBangSettingsHelper;
@@ -26,10 +27,12 @@ import org.apache.camel.main.util.CamelJBangSettingsHelper;
public class MainHttpServerFactory {
public static MainHttpServer setupHttpServer(CamelContext camelContext, boolean silent) {
- // set up a default http server on configured port if not already done
+ // if we only use management then there is no main server already
MainHttpServer server = camelContext.hasService(MainHttpServer.class);
- if (server == null) {
- // need to capture that we use a http-server
+ ManagementHttpServer managementHttpServer = camelContext.hasService(ManagementHttpServer.class);
+ // but if none has already been created, and we are using platform-http, then we need an embedded default http server
+ if (server == null && managementHttpServer == null) {
+ // set up a default http server on configured port if not already done
HttpServerConfigurationProperties config = new HttpServerConfigurationProperties(null);
CamelJBangSettingsHelper.writeSettingsIfNotExists("camel.server.port",
String.valueOf(config.getPort()));
(camel) 12/15: CAMEL-22285: platform-http-main - Dev consoles should be registered as management endpoints
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch man
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 0d01f98eaa339ec4d8c5046c3707af731de120c6
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Jul 29 20:01:45 2025 +0200
CAMEL-22285: platform-http-main - Dev consoles should be registered as management endpoints
---
.../apache/camel/dsl/jbang/core/commands/ExportBaseCommand.java | 4 ++--
.../apache/camel/dsl/jbang/core/commands/ExportCamelMain.java | 4 ++--
.../camel/dsl/jbang/core/commands/process/ListPlatformHttp.java | 2 +-
.../dsl/jbang/core/commands/kubernetes/KubernetesExport.java | 9 +++++++++
.../dsl/jbang/core/commands/kubernetes/KubernetesExportTest.java | 7 +++++++
5 files changed, 21 insertions(+), 5 deletions(-)
diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportBaseCommand.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportBaseCommand.java
index a98b709447c..cb5a4bd40f0 100644
--- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportBaseCommand.java
+++ b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportBaseCommand.java
@@ -572,11 +572,11 @@ public abstract class ExportBaseCommand extends CamelCommand {
}
// automatic add needed dependencies when main server enabled plugins
if ("true".equalsIgnoreCase(prop.getProperty("camel.management.jolokiaEnabled"))
- || "true".equalsIgnoreCase(prop.getProperty("camel.server.jolokiaEnabled"))) {
+ || "true".equalsIgnoreCase(prop.getProperty("camel.server.jolokiaEnabled"))) {
answer.add("camel:platform-http-jolokia");
}
if ("true".equalsIgnoreCase(prop.getProperty("camel.management.metricsEnabled"))
- || "true".equalsIgnoreCase(prop.getProperty("camel.server.metricsEnabled"))) {
+ || "true".equalsIgnoreCase(prop.getProperty("camel.server.metricsEnabled"))) {
answer.add("camel:micrometer-prometheus");
}
}
diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportCamelMain.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportCamelMain.java
index 8688b871ae9..cc1e7a8ae82 100644
--- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportCamelMain.java
+++ b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportCamelMain.java
@@ -363,8 +363,8 @@ class ExportCamelMain extends Export {
RuntimeUtil.loadProperties(prop, profile);
// if metrics is defined then include camel-micrometer-prometheus for camel-main runtime
if (prop.getProperty("camel.metrics.enabled") != null
- || prop.getProperty("camel.management.metricsEnabled") != null
- || prop.getProperty("camel.server.metricsEnabled") != null) {
+ || prop.getProperty("camel.management.metricsEnabled") != null
+ || prop.getProperty("camel.server.metricsEnabled") != null) {
answer.add("mvn:org.apache.camel:camel-micrometer-prometheus");
}
}
diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/ListPlatformHttp.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/ListPlatformHttp.java
index 76a5826e891..b9fbaa902b5 100644
--- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/ListPlatformHttp.java
+++ b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/ListPlatformHttp.java
@@ -46,7 +46,7 @@ public class ListPlatformHttp extends ProcessWatchCommand {
String sort;
@CommandLine.Option(names = { "--all" },
- description = "Include management endpoints")
+ description = "Include management endpoints")
boolean all;
public ListPlatformHttp(CamelJBangMain main) {
diff --git a/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/KubernetesExport.java b/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/KubernetesExport.java
index 0585c6a6711..c4efc83526e 100644
--- a/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/KubernetesExport.java
+++ b/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/KubernetesExport.java
@@ -516,6 +516,15 @@ public class KubernetesExport extends Export {
newProps.addAll(Arrays.asList(applicationProperties));
applicationProperties = newProps.toArray(new String[newProps.size()]);
}
+ } else if (RuntimeType.main == runtime) {
+ List<String> newProps = new ArrayList<>();
+ newProps.add("camel.management.port=" + (port > 0 ? "" + port : "9876"));
+ if (applicationProperties == null) {
+ applicationProperties = newProps.toArray(new String[newProps.size()]);
+ } else {
+ newProps.addAll(Arrays.asList(applicationProperties));
+ applicationProperties = newProps.toArray(new String[newProps.size()]);
+ }
}
}
diff --git a/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/test/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/KubernetesExportTest.java b/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/test/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/KubernetesExportTest.java
index 134616c2eaa..c3748cf77f0 100644
--- a/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/test/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/KubernetesExportTest.java
+++ b/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/test/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/KubernetesExportTest.java
@@ -72,7 +72,14 @@ class KubernetesExportTest extends KubernetesExportBaseTest {
Assertions.assertNull(props.get("jkube.container-image.platforms"));
if (RuntimeType.quarkus == RuntimeType.fromValue(rt.runtime())) {
+ Assertions.assertEquals("9876", props.get("quarkus.management.port"));
Assertions.assertEquals("/observe/health", props.get("quarkus.smallrye-health.root-path"));
+ } else if (RuntimeType.springBoot == RuntimeType.fromValue(rt.runtime())) {
+ Assertions.assertEquals("9876", props.get("management.server.port"));
+ Assertions.assertEquals("/observe", props.get("management.endpoints.web.base-path"));
+ Assertions.assertEquals("true", props.get("management.health.probes.enabled"));
+ } else if (RuntimeType.main == RuntimeType.fromValue(rt.runtime())) {
+ Assertions.assertEquals("9876", props.get("camel.management.port"));
}
}
(camel) 04/15: CAMEL-22285: platform-http-main - Dev consoles should be registered as management endpoints
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch man
in repository https://gitbox.apache.org/repos/asf/camel.git
commit a732fdc0b53caa4ae3cc04233eac50e0856086a8
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Jul 29 15:40:35 2025 +0200
CAMEL-22285: platform-http-main - Dev consoles should be registered as management endpoints
---
...entServerConfigurationPropertiesConfigurer.java | 7 -
...ttpServerConfigurationPropertiesConfigurer.java | 77 ------
.../camel-main-configuration-metadata.json | 12 -
core/camel-main/src/main/docs/main.adoc | 16 +-
...ttpManagementServerConfigurationProperties.java | 33 +--
.../main/HttpServerConfigurationProperties.java | 277 +--------------------
6 files changed, 18 insertions(+), 404 deletions(-)
diff --git a/core/camel-main/src/generated/java/org/apache/camel/main/HttpManagementServerConfigurationPropertiesConfigurer.java b/core/camel-main/src/generated/java/org/apache/camel/main/HttpManagementServerConfigurationPropertiesConfigurer.java
index 93bb9e9fb68..a2f420a87d2 100644
--- a/core/camel-main/src/generated/java/org/apache/camel/main/HttpManagementServerConfigurationPropertiesConfigurer.java
+++ b/core/camel-main/src/generated/java/org/apache/camel/main/HttpManagementServerConfigurationPropertiesConfigurer.java
@@ -36,7 +36,6 @@ public class HttpManagementServerConfigurationPropertiesConfigurer extends org.a
map.put("JwtKeystorePassword", java.lang.String.class);
map.put("JwtKeystorePath", java.lang.String.class);
map.put("JwtKeystoreType", java.lang.String.class);
- map.put("MaxBodySize", java.lang.Long.class);
map.put("MetricsEnabled", boolean.class);
map.put("Path", java.lang.String.class);
map.put("Port", int.class);
@@ -75,8 +74,6 @@ public class HttpManagementServerConfigurationPropertiesConfigurer extends org.a
case "jwtKeystorePath": target.setJwtKeystorePath(property(camelContext, java.lang.String.class, value)); return true;
case "jwtkeystoretype":
case "jwtKeystoreType": target.setJwtKeystoreType(property(camelContext, java.lang.String.class, value)); return true;
- case "maxbodysize":
- case "maxBodySize": target.setMaxBodySize(property(camelContext, java.lang.Long.class, value)); return true;
case "metricsenabled":
case "metricsEnabled": target.setMetricsEnabled(property(camelContext, boolean.class, value)); return true;
case "path": target.setPath(property(camelContext, java.lang.String.class, value)); return true;
@@ -123,8 +120,6 @@ public class HttpManagementServerConfigurationPropertiesConfigurer extends org.a
case "jwtKeystorePath": return java.lang.String.class;
case "jwtkeystoretype":
case "jwtKeystoreType": return java.lang.String.class;
- case "maxbodysize":
- case "maxBodySize": return java.lang.Long.class;
case "metricsenabled":
case "metricsEnabled": return boolean.class;
case "path": return java.lang.String.class;
@@ -167,8 +162,6 @@ public class HttpManagementServerConfigurationPropertiesConfigurer extends org.a
case "jwtKeystorePath": return target.getJwtKeystorePath();
case "jwtkeystoretype":
case "jwtKeystoreType": return target.getJwtKeystoreType();
- case "maxbodysize":
- case "maxBodySize": return target.getMaxBodySize();
case "metricsenabled":
case "metricsEnabled": return target.isMetricsEnabled();
case "path": return target.getPath();
diff --git a/core/camel-main/src/generated/java/org/apache/camel/main/HttpServerConfigurationPropertiesConfigurer.java b/core/camel-main/src/generated/java/org/apache/camel/main/HttpServerConfigurationPropertiesConfigurer.java
index dface0fc64b..17b45ad9a81 100644
--- a/core/camel-main/src/generated/java/org/apache/camel/main/HttpServerConfigurationPropertiesConfigurer.java
+++ b/core/camel-main/src/generated/java/org/apache/camel/main/HttpServerConfigurationPropertiesConfigurer.java
@@ -25,30 +25,19 @@ public class HttpServerConfigurationPropertiesConfigurer extends org.apache.came
map.put("AuthenticationEnabled", boolean.class);
map.put("AuthenticationPath", java.lang.String.class);
map.put("BasicPropertiesFile", java.lang.String.class);
- map.put("DevConsoleEnabled", boolean.class);
- map.put("DownloadEnabled", boolean.class);
map.put("Enabled", boolean.class);
map.put("FileUploadDirectory", java.lang.String.class);
map.put("FileUploadEnabled", boolean.class);
- map.put("HealthCheckEnabled", boolean.class);
- map.put("HealthPath", java.lang.String.class);
map.put("Host", java.lang.String.class);
- map.put("InfoEnabled", boolean.class);
- map.put("JolokiaEnabled", boolean.class);
- map.put("JolokiaPath", java.lang.String.class);
map.put("JwtKeystorePassword", java.lang.String.class);
map.put("JwtKeystorePath", java.lang.String.class);
map.put("JwtKeystoreType", java.lang.String.class);
map.put("MaxBodySize", java.lang.Long.class);
- map.put("MetricsEnabled", boolean.class);
map.put("Path", java.lang.String.class);
map.put("Port", int.class);
- map.put("SendEnabled", boolean.class);
map.put("StaticContextPath", java.lang.String.class);
map.put("StaticEnabled", boolean.class);
map.put("StaticSourceDir", java.lang.String.class);
- map.put("UploadEnabled", boolean.class);
- map.put("UploadSourceDir", java.lang.String.class);
map.put("UseGlobalSslContextParameters", boolean.class);
ALL_OPTIONS = map;
}
@@ -63,26 +52,12 @@ public class HttpServerConfigurationPropertiesConfigurer extends org.apache.came
case "authenticationPath": target.setAuthenticationPath(property(camelContext, java.lang.String.class, value)); return true;
case "basicpropertiesfile":
case "basicPropertiesFile": target.setBasicPropertiesFile(property(camelContext, java.lang.String.class, value)); return true;
- case "devconsoleenabled":
- case "devConsoleEnabled": target.setDevConsoleEnabled(property(camelContext, boolean.class, value)); return true;
- case "downloadenabled":
- case "downloadEnabled": target.setDownloadEnabled(property(camelContext, boolean.class, value)); return true;
case "enabled": target.setEnabled(property(camelContext, boolean.class, value)); return true;
case "fileuploaddirectory":
case "fileUploadDirectory": target.setFileUploadDirectory(property(camelContext, java.lang.String.class, value)); return true;
case "fileuploadenabled":
case "fileUploadEnabled": target.setFileUploadEnabled(property(camelContext, boolean.class, value)); return true;
- case "healthcheckenabled":
- case "healthCheckEnabled": target.setHealthCheckEnabled(property(camelContext, boolean.class, value)); return true;
- case "healthpath":
- case "healthPath": target.setHealthPath(property(camelContext, java.lang.String.class, value)); return true;
case "host": target.setHost(property(camelContext, java.lang.String.class, value)); return true;
- case "infoenabled":
- case "infoEnabled": target.setInfoEnabled(property(camelContext, boolean.class, value)); return true;
- case "jolokiaenabled":
- case "jolokiaEnabled": target.setJolokiaEnabled(property(camelContext, boolean.class, value)); return true;
- case "jolokiapath":
- case "jolokiaPath": target.setJolokiaPath(property(camelContext, java.lang.String.class, value)); return true;
case "jwtkeystorepassword":
case "jwtKeystorePassword": target.setJwtKeystorePassword(property(camelContext, java.lang.String.class, value)); return true;
case "jwtkeystorepath":
@@ -91,22 +66,14 @@ public class HttpServerConfigurationPropertiesConfigurer extends org.apache.came
case "jwtKeystoreType": target.setJwtKeystoreType(property(camelContext, java.lang.String.class, value)); return true;
case "maxbodysize":
case "maxBodySize": target.setMaxBodySize(property(camelContext, java.lang.Long.class, value)); return true;
- case "metricsenabled":
- case "metricsEnabled": target.setMetricsEnabled(property(camelContext, boolean.class, value)); return true;
case "path": target.setPath(property(camelContext, java.lang.String.class, value)); return true;
case "port": target.setPort(property(camelContext, int.class, value)); return true;
- case "sendenabled":
- case "sendEnabled": target.setSendEnabled(property(camelContext, boolean.class, value)); return true;
case "staticcontextpath":
case "staticContextPath": target.setStaticContextPath(property(camelContext, java.lang.String.class, value)); return true;
case "staticenabled":
case "staticEnabled": target.setStaticEnabled(property(camelContext, boolean.class, value)); return true;
case "staticsourcedir":
case "staticSourceDir": target.setStaticSourceDir(property(camelContext, java.lang.String.class, value)); return true;
- case "uploadenabled":
- case "uploadEnabled": target.setUploadEnabled(property(camelContext, boolean.class, value)); return true;
- case "uploadsourcedir":
- case "uploadSourceDir": target.setUploadSourceDir(property(camelContext, java.lang.String.class, value)); return true;
case "useglobalsslcontextparameters":
case "useGlobalSslContextParameters": target.setUseGlobalSslContextParameters(property(camelContext, boolean.class, value)); return true;
default: return false;
@@ -127,26 +94,12 @@ public class HttpServerConfigurationPropertiesConfigurer extends org.apache.came
case "authenticationPath": return java.lang.String.class;
case "basicpropertiesfile":
case "basicPropertiesFile": return java.lang.String.class;
- case "devconsoleenabled":
- case "devConsoleEnabled": return boolean.class;
- case "downloadenabled":
- case "downloadEnabled": return boolean.class;
case "enabled": return boolean.class;
case "fileuploaddirectory":
case "fileUploadDirectory": return java.lang.String.class;
case "fileuploadenabled":
case "fileUploadEnabled": return boolean.class;
- case "healthcheckenabled":
- case "healthCheckEnabled": return boolean.class;
- case "healthpath":
- case "healthPath": return java.lang.String.class;
case "host": return java.lang.String.class;
- case "infoenabled":
- case "infoEnabled": return boolean.class;
- case "jolokiaenabled":
- case "jolokiaEnabled": return boolean.class;
- case "jolokiapath":
- case "jolokiaPath": return java.lang.String.class;
case "jwtkeystorepassword":
case "jwtKeystorePassword": return java.lang.String.class;
case "jwtkeystorepath":
@@ -155,22 +108,14 @@ public class HttpServerConfigurationPropertiesConfigurer extends org.apache.came
case "jwtKeystoreType": return java.lang.String.class;
case "maxbodysize":
case "maxBodySize": return java.lang.Long.class;
- case "metricsenabled":
- case "metricsEnabled": return boolean.class;
case "path": return java.lang.String.class;
case "port": return int.class;
- case "sendenabled":
- case "sendEnabled": return boolean.class;
case "staticcontextpath":
case "staticContextPath": return java.lang.String.class;
case "staticenabled":
case "staticEnabled": return boolean.class;
case "staticsourcedir":
case "staticSourceDir": return java.lang.String.class;
- case "uploadenabled":
- case "uploadEnabled": return boolean.class;
- case "uploadsourcedir":
- case "uploadSourceDir": return java.lang.String.class;
case "useglobalsslcontextparameters":
case "useGlobalSslContextParameters": return boolean.class;
default: return null;
@@ -187,26 +132,12 @@ public class HttpServerConfigurationPropertiesConfigurer extends org.apache.came
case "authenticationPath": return target.getAuthenticationPath();
case "basicpropertiesfile":
case "basicPropertiesFile": return target.getBasicPropertiesFile();
- case "devconsoleenabled":
- case "devConsoleEnabled": return target.isDevConsoleEnabled();
- case "downloadenabled":
- case "downloadEnabled": return target.isDownloadEnabled();
case "enabled": return target.isEnabled();
case "fileuploaddirectory":
case "fileUploadDirectory": return target.getFileUploadDirectory();
case "fileuploadenabled":
case "fileUploadEnabled": return target.isFileUploadEnabled();
- case "healthcheckenabled":
- case "healthCheckEnabled": return target.isHealthCheckEnabled();
- case "healthpath":
- case "healthPath": return target.getHealthPath();
case "host": return target.getHost();
- case "infoenabled":
- case "infoEnabled": return target.isInfoEnabled();
- case "jolokiaenabled":
- case "jolokiaEnabled": return target.isJolokiaEnabled();
- case "jolokiapath":
- case "jolokiaPath": return target.getJolokiaPath();
case "jwtkeystorepassword":
case "jwtKeystorePassword": return target.getJwtKeystorePassword();
case "jwtkeystorepath":
@@ -215,22 +146,14 @@ public class HttpServerConfigurationPropertiesConfigurer extends org.apache.came
case "jwtKeystoreType": return target.getJwtKeystoreType();
case "maxbodysize":
case "maxBodySize": return target.getMaxBodySize();
- case "metricsenabled":
- case "metricsEnabled": return target.isMetricsEnabled();
case "path": return target.getPath();
case "port": return target.getPort();
- case "sendenabled":
- case "sendEnabled": return target.isSendEnabled();
case "staticcontextpath":
case "staticContextPath": return target.getStaticContextPath();
case "staticenabled":
case "staticEnabled": return target.isStaticEnabled();
case "staticsourcedir":
case "staticSourceDir": return target.getStaticSourceDir();
- case "uploadenabled":
- case "uploadEnabled": return target.isUploadEnabled();
- case "uploadsourcedir":
- case "uploadSourceDir": return target.getUploadSourceDir();
case "useglobalsslcontextparameters":
case "useGlobalSslContextParameters": return target.isUseGlobalSslContextParameters();
default: return null;
diff --git a/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json b/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json
index d28e97682aa..0fe6ab967ee 100644
--- a/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json
+++ b/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json
@@ -205,7 +205,6 @@
{ "name": "camel.management.jwtKeystorePassword", "description": "Password from the keystore used for JWT tokens validation.", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "string", "javaType": "java.lang.String" },
{ "name": "camel.management.jwtKeystorePath", "description": "Path to the keystore file used for JWT tokens validation.", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "string", "javaType": "java.lang.String" },
{ "name": "camel.management.jwtKeystoreType", "description": "Type of the keystore used for JWT tokens validation (jks, pkcs12, etc.).", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "string", "javaType": "java.lang.String" },
- { "name": "camel.management.maxBodySize", "description": "Maximum HTTP body size the embedded HTTP server can accept.", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "integer", "javaType": "java.lang.Long" },
{ "name": "camel.management.metricsEnabled", "description": "Whether to enable metrics. If enabled then you can access metrics on context-path: \/q\/metrics (default)", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
{ "name": "camel.management.path", "description": "Context-path to use for embedded HTTP server", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "string", "javaType": "java.lang.String", "defaultValue": "\/" },
{ "name": "camel.management.port", "description": "Port to use for binding embedded HTTP server", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "integer", "javaType": "int", "defaultValue": 9876 },
@@ -301,30 +300,19 @@
{ "name": "camel.server.authenticationEnabled", "description": "Whether to enable HTTP authentication for embedded server (for standalone applications; not Spring Boot or Quarkus).", "sourceType": "org.apache.camel.main.HttpServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
{ "name": "camel.server.authenticationPath", "description": "Set HTTP url path of embedded server that is protected by authentication configuration.", "sourceType": "org.apache.camel.main.HttpServerConfigurationProperties", "type": "string", "javaType": "java.lang.String" },
{ "name": "camel.server.basicPropertiesFile", "description": "Name of the file that contains basic authentication info for Vert.x file auth provider.", "sourceType": "org.apache.camel.main.HttpServerConfigurationProperties", "type": "string", "javaType": "java.lang.String" },
- { "name": "camel.server.devConsoleEnabled", "description": "Whether to enable developer console (not intended for production use). Dev console must also be enabled on CamelContext. For example by setting camel.context.dev-console=true in application.properties, or via code camelContext.setDevConsole(true); If enabled then you can access a basic developer console on context-path: \/q\/dev. Deprecated since 4.12.0, use HTTP management server instead.", "sourceType": "org.apache.camel.m [...]
- { "name": "camel.server.downloadEnabled", "description": "Whether to enable file download via HTTP. This makes it possible to browse and download resource source files such as Camel XML or YAML routes. Only enable this for development, troubleshooting or special situations for management and monitoring.", "sourceType": "org.apache.camel.main.HttpServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
{ "name": "camel.server.enabled", "description": "Whether embedded HTTP server is enabled. By default, the server is not enabled.", "sourceType": "org.apache.camel.main.HttpServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
{ "name": "camel.server.fileUploadDirectory", "description": "Directory to temporary store file uploads while Camel routes the incoming request. If no directory has been explicit configured, then a temporary directory is created in the java.io.tmpdir directory.", "sourceType": "org.apache.camel.main.HttpServerConfigurationProperties", "type": "string", "javaType": "java.lang.String" },
{ "name": "camel.server.fileUploadEnabled", "description": "Whether to enable file uploads being supported (such as POST multipart\/form-data) and stored into a temporary directory.", "sourceType": "org.apache.camel.main.HttpServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": true },
- { "name": "camel.server.healthCheckEnabled", "description": "Whether to enable health-check console. If enabled then you can access health-check status on context-path: \/q\/health (default). Deprecated since 4.12.0, use HTTP management server instead.", "sourceType": "org.apache.camel.main.HttpServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
- { "name": "camel.server.healthPath", "description": "The path endpoint used to expose the health status. Deprecated since 4.12.0, use HTTP management server instead.", "sourceType": "org.apache.camel.main.HttpServerConfigurationProperties", "type": "string", "javaType": "java.lang.String", "defaultValue": "\/q\/health" },
{ "name": "camel.server.host", "description": "Hostname to use for binding embedded HTTP server", "sourceType": "org.apache.camel.main.HttpServerConfigurationProperties", "type": "string", "javaType": "java.lang.String", "defaultValue": "0.0.0.0" },
- { "name": "camel.server.infoEnabled", "description": "Whether to enable info console. If enabled then you can see some basic Camel information at \/q\/info. Deprecated since 4.12.0, use HTTP management server instead.", "sourceType": "org.apache.camel.main.HttpServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
- { "name": "camel.server.jolokiaEnabled", "description": "Whether to enable jolokia. If enabled then you can access jolokia api on context-path: \/q\/jolokia. Deprecated since 4.12.0, use HTTP management server instead.", "sourceType": "org.apache.camel.main.HttpServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
- { "name": "camel.server.jolokiaPath", "description": "The path endpoint used to expose the jolokia data. Deprecated since 4.12.0, use HTTP management server instead.", "sourceType": "org.apache.camel.main.HttpServerConfigurationProperties", "type": "string", "javaType": "java.lang.String", "defaultValue": "\/q\/jolokia" },
{ "name": "camel.server.jwtKeystorePassword", "description": "Password from the keystore used for JWT tokens validation.", "sourceType": "org.apache.camel.main.HttpServerConfigurationProperties", "type": "string", "javaType": "java.lang.String" },
{ "name": "camel.server.jwtKeystorePath", "description": "Path to the keystore file used for JWT tokens validation.", "sourceType": "org.apache.camel.main.HttpServerConfigurationProperties", "type": "string", "javaType": "java.lang.String" },
{ "name": "camel.server.jwtKeystoreType", "description": "Type of the keystore used for JWT tokens validation (jks, pkcs12, etc.).", "sourceType": "org.apache.camel.main.HttpServerConfigurationProperties", "type": "string", "javaType": "java.lang.String" },
{ "name": "camel.server.maxBodySize", "description": "Maximum HTTP body size the embedded HTTP server can accept.", "sourceType": "org.apache.camel.main.HttpServerConfigurationProperties", "type": "integer", "javaType": "java.lang.Long" },
- { "name": "camel.server.metricsEnabled", "description": "Whether to enable metrics. If enabled then you can access metrics on context-path: \/q\/metrics (default). Deprecated since 4.12.0, use HTTP management server instead.", "sourceType": "org.apache.camel.main.HttpServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
{ "name": "camel.server.path", "description": "Context-path to use for embedded HTTP server", "sourceType": "org.apache.camel.main.HttpServerConfigurationProperties", "type": "string", "javaType": "java.lang.String", "defaultValue": "\/" },
{ "name": "camel.server.port", "description": "Port to use for binding embedded HTTP server", "sourceType": "org.apache.camel.main.HttpServerConfigurationProperties", "type": "integer", "javaType": "int", "defaultValue": 8080 },
- { "name": "camel.server.sendEnabled", "description": "Whether to enable sending messages to Camel via HTTP. This makes it possible to use Camel to send messages to Camel endpoint URIs via HTTP.", "sourceType": "org.apache.camel.main.HttpServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
{ "name": "camel.server.staticContextPath", "description": "The context-path to use for serving static content. By default, the root path is used. And if there is an index.html page then this is automatically loaded.", "sourceType": "org.apache.camel.main.HttpServerConfigurationProperties", "type": "string", "javaType": "java.lang.String", "defaultValue": "\/" },
{ "name": "camel.server.staticEnabled", "description": "Whether serving static files is enabled. If enabled then Camel can host html\/js and other web files that makes it possible to include small web applications.", "sourceType": "org.apache.camel.main.HttpServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
{ "name": "camel.server.staticSourceDir", "description": "Additional directory that holds static content when static is enabled.", "sourceType": "org.apache.camel.main.HttpServerConfigurationProperties", "type": "string", "javaType": "java.lang.String" },
- { "name": "camel.server.uploadEnabled", "description": "Whether to enable file upload via HTTP (not intended for production use). This functionality is for development to be able to reload Camel routes and code with source changes (if reload is enabled). If enabled then you can upload\/delete files via HTTP PUT\/DELETE on context-path: \/q\/upload\/{name}. You must also configure the uploadSourceDir option.", "sourceType": "org.apache.camel.main.HttpServerConfigurationProperties", "t [...]
- { "name": "camel.server.uploadSourceDir", "description": "Source directory when upload is enabled.", "sourceType": "org.apache.camel.main.HttpServerConfigurationProperties", "type": "string", "javaType": "java.lang.String" },
{ "name": "camel.server.useGlobalSslContextParameters", "description": "Whether to use global SSL configuration for securing the embedded HTTP server.", "sourceType": "org.apache.camel.main.HttpServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
{ "name": "camel.ssl.certAlias", "description": "An optional certificate alias to use. This is useful when the keystore has multiple certificates.", "sourceType": "org.apache.camel.main.SSLConfigurationProperties", "type": "string", "javaType": "java.lang.String" },
{ "name": "camel.ssl.cipherSuites", "description": "List of TLS\/SSL cipher suite algorithm names. Multiple names can be separated by comma.", "sourceType": "org.apache.camel.main.SSLConfigurationProperties", "type": "string", "javaType": "java.lang.String" },
diff --git a/core/camel-main/src/main/docs/main.adoc b/core/camel-main/src/main/docs/main.adoc
index 67a783f0125..f50aa19a745 100644
--- a/core/camel-main/src/main/docs/main.adoc
+++ b/core/camel-main/src/main/docs/main.adoc
@@ -189,7 +189,7 @@ The camel.routecontroller supports 12 options, which are listed below.
=== Camel Embedded HTTP Server (only for standalone; not Spring Boot or Quarkus) configurations
-The camel.server supports 28 options, which are listed below.
+The camel.server supports 17 options, which are listed below.
[width="100%",cols="2,5,^1,2",options="header"]
|===
@@ -197,36 +197,25 @@ The camel.server supports 28 options, which are listed below.
| *camel.server.authentication{zwsp}Enabled* | Whether to enable HTTP authentication for embedded server (for standalone applications; not Spring Boot or Quarkus). | false | boolean
| *camel.server.authentication{zwsp}Path* | Set HTTP url path of embedded server that is protected by authentication configuration. | | String
| *camel.server.basicProperties{zwsp}File* | Name of the file that contains basic authentication info for Vert.x file auth provider. | | String
-| *camel.server.devConsoleEnabled* | Whether to enable developer console (not intended for production use). Dev console must also be enabled on CamelContext. For example by setting camel.context.dev-console=true in application.properties, or via code camelContext.setDevConsole(true); If enabled then you can access a basic developer console on context-path: /q/dev. Deprecated since 4.12.0, use HTTP management server instead. | false | boolean
-| *camel.server.downloadEnabled* | Whether to enable file download via HTTP. This makes it possible to browse and download resource source files such as Camel XML or YAML routes. Only enable this for development, troubleshooting or special situations for management and monitoring. | false | boolean
| *camel.server.enabled* | Whether embedded HTTP server is enabled. By default, the server is not enabled. | false | boolean
| *camel.server.fileUpload{zwsp}Directory* | Directory to temporary store file uploads while Camel routes the incoming request. If no directory has been explicit configured, then a temporary directory is created in the java.io.tmpdir directory. | | String
| *camel.server.fileUploadEnabled* | Whether to enable file uploads being supported (such as POST multipart/form-data) and stored into a temporary directory. | true | boolean
-| *camel.server.healthCheck{zwsp}Enabled* | Whether to enable health-check console. If enabled then you can access health-check status on context-path: /q/health (default). Deprecated since 4.12.0, use HTTP management server instead. | false | boolean
-| *camel.server.healthPath* | The path endpoint used to expose the health status. Deprecated since 4.12.0, use HTTP management server instead. | /q/health | String
| *camel.server.host* | Hostname to use for binding embedded HTTP server | 0.0.0.0 | String
-| *camel.server.infoEnabled* | Whether to enable info console. If enabled then you can see some basic Camel information at /q/info. Deprecated since 4.12.0, use HTTP management server instead. | false | boolean
-| *camel.server.jolokiaEnabled* | Whether to enable jolokia. If enabled then you can access jolokia api on context-path: /q/jolokia. Deprecated since 4.12.0, use HTTP management server instead. | false | boolean
-| *camel.server.jolokiaPath* | The path endpoint used to expose the jolokia data. Deprecated since 4.12.0, use HTTP management server instead. | /q/jolokia | String
| *camel.server.jwtKeystore{zwsp}Password* | Password from the keystore used for JWT tokens validation. | | String
| *camel.server.jwtKeystorePath* | Path to the keystore file used for JWT tokens validation. | | String
| *camel.server.jwtKeystoreType* | Type of the keystore used for JWT tokens validation (jks, pkcs12, etc.). | | String
| *camel.server.maxBodySize* | Maximum HTTP body size the embedded HTTP server can accept. | | Long
-| *camel.server.metricsEnabled* | Whether to enable metrics. If enabled then you can access metrics on context-path: /q/metrics (default). Deprecated since 4.12.0, use HTTP management server instead. | false | boolean
| *camel.server.path* | Context-path to use for embedded HTTP server | / | String
| *camel.server.port* | Port to use for binding embedded HTTP server | 8080 | int
-| *camel.server.sendEnabled* | Whether to enable sending messages to Camel via HTTP. This makes it possible to use Camel to send messages to Camel endpoint URIs via HTTP. | false | boolean
| *camel.server.staticContextPath* | The context-path to use for serving static content. By default, the root path is used. And if there is an index.html page then this is automatically loaded. | / | String
| *camel.server.staticEnabled* | Whether serving static files is enabled. If enabled then Camel can host html/js and other web files that makes it possible to include small web applications. | false | boolean
| *camel.server.staticSourceDir* | Additional directory that holds static content when static is enabled. | | String
-| *camel.server.uploadEnabled* | Whether to enable file upload via HTTP (not intended for production use). This functionality is for development to be able to reload Camel routes and code with source changes (if reload is enabled). If enabled then you can upload/delete files via HTTP PUT/DELETE on context-path: /q/upload/\{name}. You must also configure the uploadSourceDir option. | false | boolean
-| *camel.server.uploadSourceDir* | Source directory when upload is enabled. | | String
| *camel.server.useGlobalSsl{zwsp}ContextParameters* | Whether to use global SSL configuration for securing the embedded HTTP server. | false | boolean
|===
=== Camel Embedded HTTP management Server (only for standalone; not Spring Boot or Quarkus) configurations
-The camel.management supports 20 options, which are listed below.
+The camel.management supports 19 options, which are listed below.
[width="100%",cols="2,5,^1,2",options="header"]
|===
@@ -245,7 +234,6 @@ The camel.management supports 20 options, which are listed below.
| *camel.management.jwtKeystore{zwsp}Password* | Password from the keystore used for JWT tokens validation. | | String
| *camel.management.jwtKeystore{zwsp}Path* | Path to the keystore file used for JWT tokens validation. | | String
| *camel.management.jwtKeystore{zwsp}Type* | Type of the keystore used for JWT tokens validation (jks, pkcs12, etc.). | | String
-| *camel.management.maxBodySize* | Maximum HTTP body size the embedded HTTP server can accept. | | Long
| *camel.management.metrics{zwsp}Enabled* | Whether to enable metrics. If enabled then you can access metrics on context-path: /q/metrics (default) | false | boolean
| *camel.management.path* | Context-path to use for embedded HTTP server | / | String
| *camel.management.port* | Port to use for binding embedded HTTP server | 9876 | int
diff --git a/core/camel-main/src/main/java/org/apache/camel/main/HttpManagementServerConfigurationProperties.java b/core/camel-main/src/main/java/org/apache/camel/main/HttpManagementServerConfigurationProperties.java
index 521a4be8197..a157c0e35a2 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/HttpManagementServerConfigurationProperties.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/HttpManagementServerConfigurationProperties.java
@@ -36,8 +36,11 @@ public class HttpManagementServerConfigurationProperties implements BootstrapClo
private int port = 9876;
@Metadata(defaultValue = "/")
private String path = "/";
- private Long maxBodySize;
- private boolean useGlobalSslContextParameters;
+ @Metadata(defaultValue = "/observe/health")
+ private String healthPath = "/observe/health";
+ @Metadata(defaultValue = "/observe/jolokia")
+ private String jolokiaPath = "/observe/jolokia";
+
private boolean infoEnabled;
private boolean devConsoleEnabled;
private boolean healthCheckEnabled;
@@ -45,6 +48,8 @@ public class HttpManagementServerConfigurationProperties implements BootstrapClo
private boolean metricsEnabled;
private boolean sendEnabled;
+ @Metadata(label = "security")
+ private boolean useGlobalSslContextParameters;
@Metadata(label = "security")
private boolean authenticationEnabled;
@Metadata(label = "security")
@@ -58,11 +63,6 @@ public class HttpManagementServerConfigurationProperties implements BootstrapClo
@Metadata(label = "security", secret = true)
private String jwtKeystorePassword;
- @Metadata(defaultValue = "/observe/health")
- private String healthPath = "/observe/health";
- @Metadata(defaultValue = "/observe/jolokia")
- private String jolokiaPath = "/observe/jolokia";
-
public HttpManagementServerConfigurationProperties(MainConfigurationProperties parent) {
this.parent = parent;
}
@@ -120,17 +120,6 @@ public class HttpManagementServerConfigurationProperties implements BootstrapClo
this.path = path;
}
- public Long getMaxBodySize() {
- return maxBodySize;
- }
-
- /**
- * Maximum HTTP body size the embedded HTTP server can accept.
- */
- public void setMaxBodySize(Long maxBodySize) {
- this.maxBodySize = maxBodySize;
- }
-
public boolean isUseGlobalSslContextParameters() {
return useGlobalSslContextParameters;
}
@@ -334,14 +323,6 @@ public class HttpManagementServerConfigurationProperties implements BootstrapClo
return this;
}
- /**
- * Maximum HTTP body size the embedded HTTP management server can accept.
- */
- public HttpManagementServerConfigurationProperties withMaxBodySize(long maxBodySize) {
- this.maxBodySize = maxBodySize;
- return this;
- }
-
/**
* Whether to use global SSL configuration for securing the embedded HTTP management server.
*/
diff --git a/core/camel-main/src/main/java/org/apache/camel/main/HttpServerConfigurationProperties.java b/core/camel-main/src/main/java/org/apache/camel/main/HttpServerConfigurationProperties.java
index 3b16350796b..1172c9464b2 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/HttpServerConfigurationProperties.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/HttpServerConfigurationProperties.java
@@ -36,31 +36,20 @@ public class HttpServerConfigurationProperties implements BootstrapCloseable {
private int port = 8080;
@Metadata(defaultValue = "/")
private String path = "/";
- private Long maxBodySize;
- private boolean useGlobalSslContextParameters;
- @Metadata(defaultValue = "true")
- private boolean fileUploadEnabled = true;
- @Metadata
- private String fileUploadDirectory;
- @Deprecated
- private boolean infoEnabled;
+
private boolean staticEnabled;
private String staticSourceDir;
@Metadata(defaultValue = "/")
private String staticContextPath = "/";
- @Deprecated
- private boolean devConsoleEnabled;
- @Deprecated
- private boolean healthCheckEnabled;
- @Deprecated
- private boolean jolokiaEnabled;
- @Deprecated
- private boolean metricsEnabled;
- private boolean uploadEnabled;
- private String uploadSourceDir;
- private boolean downloadEnabled;
- private boolean sendEnabled;
+ @Metadata(label = "advanced", defaultValue = "true")
+ private boolean fileUploadEnabled = true;
+ @Metadata(label = "advanced")
+ private String fileUploadDirectory;
+ @Metadata(label = "advanced")
+ private Long maxBodySize;
+ @Metadata(label = "security")
+ private boolean useGlobalSslContextParameters;
@Metadata(label = "security")
private boolean authenticationEnabled;
@Metadata(label = "security")
@@ -74,13 +63,6 @@ public class HttpServerConfigurationProperties implements BootstrapCloseable {
@Metadata(label = "security", secret = true)
private String jwtKeystorePassword;
- @Deprecated
- @Metadata(defaultValue = "/q/health")
- private String healthPath = "/q/health";
- @Deprecated
- @Metadata(defaultValue = "/q/jolokia")
- private String jolokiaPath = "/q/jolokia";
-
public HttpServerConfigurationProperties(MainConfigurationProperties parent) {
this.parent = parent;
}
@@ -186,19 +168,6 @@ public class HttpServerConfigurationProperties implements BootstrapCloseable {
this.fileUploadDirectory = fileUploadDirectory;
}
- @Deprecated(since = "4.12.0")
- public boolean isInfoEnabled() {
- return infoEnabled;
- }
-
- /**
- * Whether to enable info console. If enabled then you can see some basic Camel information at /q/info. Deprecated
- * since 4.12.0, use HTTP management server instead.
- */
- public void setInfoEnabled(boolean infoEnabled) {
- this.infoEnabled = infoEnabled;
- }
-
public boolean isStaticEnabled() {
return staticEnabled;
}
@@ -234,133 +203,6 @@ public class HttpServerConfigurationProperties implements BootstrapCloseable {
this.staticContextPath = staticContextPath;
}
- public boolean isDevConsoleEnabled() {
- return devConsoleEnabled;
- }
-
- /**
- * Whether to enable developer console (not intended for production use). Dev console must also be enabled on
- * CamelContext. For example by setting camel.context.dev-console=true in application.properties, or via code
- * <tt>camelContext.setDevConsole(true);</tt> If enabled then you can access a basic developer console on
- * context-path: /q/dev. Deprecated since 4.12.0, use HTTP management server instead.
- */
- public void setDevConsoleEnabled(boolean devConsoleEnabled) {
- this.devConsoleEnabled = devConsoleEnabled;
- }
-
- @Deprecated(since = "4.12.0")
- public boolean isHealthCheckEnabled() {
- return healthCheckEnabled;
- }
-
- /**
- * Whether to enable health-check console. If enabled then you can access health-check status on context-path:
- * /q/health (default). Deprecated since 4.12.0, use HTTP management server instead.
- */
- public void setHealthCheckEnabled(boolean healthCheckEnabled) {
- this.healthCheckEnabled = healthCheckEnabled;
- }
-
- @Deprecated(since = "4.12.0")
- public boolean isJolokiaEnabled() {
- return jolokiaEnabled;
- }
-
- /**
- * Whether to enable jolokia. If enabled then you can access jolokia api on context-path: /q/jolokia. Deprecated
- * since 4.12.0, use HTTP management server instead.
- */
- public void setJolokiaEnabled(boolean jolokiaEnabled) {
- this.jolokiaEnabled = jolokiaEnabled;
- }
-
- @Deprecated(since = "4.12.0")
- public boolean isMetricsEnabled() {
- return metricsEnabled;
- }
-
- /**
- * Whether to enable metrics. If enabled then you can access metrics on context-path: /q/metrics (default).
- * Deprecated since 4.12.0, use HTTP management server instead.
- */
- public void setMetricsEnabled(boolean metricsEnabled) {
- this.metricsEnabled = metricsEnabled;
- }
-
- @Deprecated(since = "4.12.0")
- public String getHealthPath() {
- return healthPath;
- }
-
- /**
- * The path endpoint used to expose the health status. Deprecated since 4.12.0, use HTTP management server instead.
- */
- public void setHealthPath(String healthPath) {
- this.healthPath = healthPath;
- }
-
- @Deprecated(since = "4.12.0")
- public String getJolokiaPath() {
- return jolokiaPath;
- }
-
- /**
- * The path endpoint used to expose the jolokia data. Deprecated since 4.12.0, use HTTP management server instead.
- */
- public void setJolokiaPath(String jolokiaPath) {
- this.jolokiaPath = jolokiaPath;
- }
-
- public boolean isUploadEnabled() {
- return uploadEnabled;
- }
-
- /**
- * Whether to enable file upload via HTTP (not intended for production use). This functionality is for development
- * to be able to reload Camel routes and code with source changes (if reload is enabled). If enabled then you can
- * upload/delete files via HTTP PUT/DELETE on context-path: /q/upload/{name}. You must also configure the
- * uploadSourceDir option.
- */
- public void setUploadEnabled(boolean uploadEnabled) {
- this.uploadEnabled = uploadEnabled;
- }
-
- public String getUploadSourceDir() {
- return uploadSourceDir;
- }
-
- /**
- * Source directory when upload is enabled.
- */
- public void setUploadSourceDir(String uploadSourceDir) {
- this.uploadSourceDir = uploadSourceDir;
- }
-
- public boolean isDownloadEnabled() {
- return downloadEnabled;
- }
-
- /**
- * Whether to enable file download via HTTP. This makes it possible to browse and download resource source files
- * such as Camel XML or YAML routes. Only enable this for development, troubleshooting or special situations for
- * management and monitoring.
- */
- public void setDownloadEnabled(boolean downloadEnabled) {
- this.downloadEnabled = downloadEnabled;
- }
-
- public boolean isSendEnabled() {
- return sendEnabled;
- }
-
- /**
- * Whether to enable sending messages to Camel via HTTP. This makes it possible to use Camel to send messages to
- * Camel endpoint URIs via HTTP.
- */
- public void setSendEnabled(boolean sendEnabled) {
- this.sendEnabled = sendEnabled;
- }
-
public boolean isAuthenticationEnabled() {
return authenticationEnabled;
}
@@ -496,14 +338,6 @@ public class HttpServerConfigurationProperties implements BootstrapCloseable {
return this;
}
- /**
- * Whether to enable info console. If enabled then you can see some basic Camel information at /q/info
- */
- public HttpServerConfigurationProperties withInfoEnabled(boolean infoEnabled) {
- this.infoEnabled = infoEnabled;
- return this;
- }
-
/**
* Whether serving static files is enabled. If enabled then Camel can host html/js and other web files that makes it
* possible to include small web applications.
@@ -530,83 +364,6 @@ public class HttpServerConfigurationProperties implements BootstrapCloseable {
return this;
}
- /**
- *
- * Whether to enable developer console (not intended for production use). Dev console must also be enabled on
- * CamelContext. For example by setting camel.context.dev-console=true in application.properties, or via code
- * <tt>camelContext.setDevConsole(true);</tt> If enabled then you can access a basic developer console on
- * context-path: /q/dev. Deprecated since 4.12.0, use HTTP management server instead.
- */
- public HttpServerConfigurationProperties withDevConsoleEnabled(boolean devConsoleEnabled) {
- this.devConsoleEnabled = devConsoleEnabled;
- return this;
- }
-
- /**
- * Whether to enable health-check console. If enabled then you can access health-check status on context-path:
- * /q/health (default). Deprecated since 4.12.0, use HTTP management server instead.
- */
- public HttpServerConfigurationProperties withHealthCheckEnabled(boolean healthCheckEnabled) {
- this.healthCheckEnabled = healthCheckEnabled;
- return this;
- }
-
- /**
- * Whether to enable jolokia. If enabled then you can access jolokia api on context-path: /q/jolokia. Deprecated
- * since 4.12.0, use HTTP management server instead.
- */
- public HttpServerConfigurationProperties withJolokiaEnabled(boolean jolokiaEnabled) {
- this.jolokiaEnabled = jolokiaEnabled;
- return this;
- }
-
- /**
- * Whether to enable metrics. If enabled then you can access metrics on context-path: /q/metrics (default).
- * Deprecated since 4.12.0, use HTTP management server instead.
- */
- public HttpServerConfigurationProperties withMetricsEnabled(boolean metricsEnabled) {
- this.metricsEnabled = metricsEnabled;
- return this;
- }
-
- /**
- * Whether to enable file upload via HTTP (not intended for production use). This functionality is for development
- * to be able to reload Camel routes and code with source changes (if reload is enabled). If enabled then you can
- * upload/delete files via HTTP PUT/DELETE on context-path: /q/upload/{name}. You must also configure the
- * uploadSourceDir option.
- */
- public HttpServerConfigurationProperties withUploadEnabled(boolean uploadEnabled) {
- this.uploadEnabled = uploadEnabled;
- return this;
- }
-
- /**
- * Source directory when upload is enabled.
- */
- public HttpServerConfigurationProperties withUploadSourceDir(String uploadSourceDir) {
- this.uploadSourceDir = uploadSourceDir;
- return this;
- }
-
- /**
- * Whether to enable file download via HTTP. This makes it possible to browse and download resource source files
- * such as Camel XML or YAML routes. Only enable this for development, troubleshooting or special situations for
- * management and monitoring.
- */
- public HttpServerConfigurationProperties withDownloadEnabled(boolean downloadEnabled) {
- this.downloadEnabled = downloadEnabled;
- return this;
- }
-
- /**
- * Whether to enable sending messages to Camel via HTTP. This makes it possible to use Camel to send messages to
- * Camel endpoint URIs via HTTP.
- */
- public HttpServerConfigurationProperties withSendEnabled(boolean sendEnabled) {
- this.sendEnabled = sendEnabled;
- return this;
- }
-
/**
* Whether to enable HTTP authentication for embedded server (for standalone applications; not Spring Boot or
* Quarkus).
@@ -656,20 +413,4 @@ public class HttpServerConfigurationProperties implements BootstrapCloseable {
return this;
}
- /**
- * The path endpoint used to expose the health status
- */
- public HttpServerConfigurationProperties withHealthPath(String healthPath) {
- this.healthPath = healthPath;
- return this;
- }
-
- /**
- * The path endpoint used to expose the jolokia data. Deprecated since 4.12.0, use HTTP management server instead.
- */
- public HttpServerConfigurationProperties withJolokiaPath(String jolokiaPath) {
- this.jolokiaPath = jolokiaPath;
- return this;
- }
-
}
(camel) 02/15: CAMEL-22285: platform-http-main - Dev consoles should be registered as management endpoints
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch man
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 676f9889fd53eb20e2dfd51b32b694548eb403c2
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Jul 29 07:18:08 2025 +0200
CAMEL-22285: platform-http-main - Dev consoles should be registered as management endpoints
---
.../camel/component/platform/http/main/MainHttpServer.java | 12 ++++++------
.../component/platform/http/main/ManagementHttpServer.java | 6 +++---
2 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/MainHttpServer.java b/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/MainHttpServer.java
index 234cef965bd..2d0c28182b8 100644
--- a/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/MainHttpServer.java
+++ b/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/MainHttpServer.java
@@ -175,7 +175,7 @@ public class MainHttpServer extends ServiceSupport implements CamelContextAware,
configuration.getBodyHandler().setUploadsDirectory(fileUploadDirectory);
}
- @ManagedAttribute(description = "Whether info is enabled (/q/info)")
+ @ManagedAttribute(description = "Whether info is enabled")
@Deprecated(since = "4.12.0")
public boolean isInfoEnabled() {
return infoEnabled;
@@ -220,7 +220,7 @@ public class MainHttpServer extends ServiceSupport implements CamelContextAware,
return staticEnabled;
}
- @ManagedAttribute(description = "Whether dev console is enabled (/q/dev)")
+ @ManagedAttribute(description = "Whether dev console is enabled")
@Deprecated(since = "4.12.0")
public boolean isDevConsoleEnabled() {
return devConsoleEnabled;
@@ -239,7 +239,7 @@ public class MainHttpServer extends ServiceSupport implements CamelContextAware,
return healthCheckEnabled;
}
- @ManagedAttribute(description = "Whether Jolokia is enabled (q/jolokia)")
+ @ManagedAttribute(description = "Whether Jolokia is enabled")
@Deprecated(since = "4.12.0")
public boolean isJolokiaEnabled() {
return jolokiaEnabled;
@@ -296,7 +296,7 @@ public class MainHttpServer extends ServiceSupport implements CamelContextAware,
this.metricsEnabled = metricsEnabled;
}
- @ManagedAttribute(description = "Whether file upload is enabled (only for development) (q/upload)")
+ @ManagedAttribute(description = "Whether file upload is enabled (only for development)")
public boolean isUploadEnabled() {
return uploadEnabled;
}
@@ -320,7 +320,7 @@ public class MainHttpServer extends ServiceSupport implements CamelContextAware,
this.uploadSourceDir = uploadSourceDir;
}
- @ManagedAttribute(description = "Whether file download is enabled (q/download)")
+ @ManagedAttribute(description = "Whether file download is enabled")
public boolean isDownloadEnabled() {
return downloadEnabled;
}
@@ -332,7 +332,7 @@ public class MainHttpServer extends ServiceSupport implements CamelContextAware,
this.downloadEnabled = downloadEnabled;
}
- @ManagedAttribute(description = "Whether send message is enabled (q/send)")
+ @ManagedAttribute(description = "Whether send message is enabled")
public boolean isSendEnabled() {
return sendEnabled;
}
diff --git a/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/ManagementHttpServer.java b/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/ManagementHttpServer.java
index 9063452af11..6adabac1153 100644
--- a/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/ManagementHttpServer.java
+++ b/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/ManagementHttpServer.java
@@ -148,7 +148,7 @@ public class ManagementHttpServer extends ServiceSupport implements CamelContext
configuration.getBodyHandler().setUploadsDirectory(fileUploadDirectory);
}
- @ManagedAttribute(description = "Whether info is enabled (/observe/info)")
+ @ManagedAttribute(description = "Whether info is enabled")
public boolean isInfoEnabled() {
return infoEnabled;
}
@@ -157,7 +157,7 @@ public class ManagementHttpServer extends ServiceSupport implements CamelContext
this.infoEnabled = infoEnabled;
}
- @ManagedAttribute(description = "Whether dev console is enabled (/observe/dev)")
+ @ManagedAttribute(description = "Whether dev console is enabled")
public boolean isDevConsoleEnabled() {
return devConsoleEnabled;
}
@@ -174,7 +174,7 @@ public class ManagementHttpServer extends ServiceSupport implements CamelContext
return healthCheckEnabled;
}
- @ManagedAttribute(description = "Whether Jolokia is enabled (observe/jolokia)")
+ @ManagedAttribute(description = "Whether Jolokia is enabled")
public boolean isJolokiaEnabled() {
return jolokiaEnabled;
}
(camel) 06/15: CAMEL-22285: platform-http-main - Dev consoles should be registered as management endpoints
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch man
in repository https://gitbox.apache.org/repos/asf/camel.git
commit c4aeba686c12e98dac962239669dffa1684e00aa
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Jul 29 16:20:29 2025 +0200
CAMEL-22285: platform-http-main - Dev consoles should be registered as management endpoints
---
.../main/camel-main-configuration-metadata.json | 17 ++------
.../src/main/docs/micrometer-prometheus.adoc | 6 +--
.../prometheus/MicrometerPrometheus.java | 45 ++++++----------------
.../ROOT/pages/camel-4x-upgrade-guide-4_14.adoc | 7 ++++
.../java/org/apache/camel/main/KameletMain.java | 32 +++++++--------
5 files changed, 42 insertions(+), 65 deletions(-)
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/camel-main-configuration-metadata.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/camel-main-configuration-metadata.json
index d28e97682aa..66eff52bf6b 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/camel-main-configuration-metadata.json
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/camel-main-configuration-metadata.json
@@ -195,6 +195,7 @@
{ "name": "camel.management.authenticationPath", "description": "Set HTTP url path of embedded server that is protected by authentication configuration.", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "string", "javaType": "java.lang.String" },
{ "name": "camel.management.basicPropertiesFile", "description": "Name of the file that contains basic authentication info for Vert.x file auth provider.", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "string", "javaType": "java.lang.String" },
{ "name": "camel.management.devConsoleEnabled", "description": "Whether to enable developer console (not intended for production use). Dev console must also be enabled on CamelContext. For example by setting camel.context.dev-console=true in application.properties, or via code camelContext.setDevConsole(true); If enabled then you can access a basic developer console on context-path: \/q\/dev.", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": [...]
+ { "name": "camel.management.downloadEnabled", "description": "Whether to enable file download via HTTP. This makes it possible to browse and download resource source files such as Camel XML or YAML routes. Only enable this for development, troubleshooting or special situations for management and monitoring.", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
{ "name": "camel.management.enabled", "description": "Whether embedded HTTP server is enabled. By default, the server is not enabled.", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
{ "name": "camel.management.healthCheckEnabled", "description": "Whether to enable health-check console. If enabled then you can access health-check status on context-path: \/q\/health (default)", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
{ "name": "camel.management.healthPath", "description": "The path endpoint used to expose the health status", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "string", "javaType": "java.lang.String", "defaultValue": "\/observe\/health" },
@@ -205,11 +206,12 @@
{ "name": "camel.management.jwtKeystorePassword", "description": "Password from the keystore used for JWT tokens validation.", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "string", "javaType": "java.lang.String" },
{ "name": "camel.management.jwtKeystorePath", "description": "Path to the keystore file used for JWT tokens validation.", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "string", "javaType": "java.lang.String" },
{ "name": "camel.management.jwtKeystoreType", "description": "Type of the keystore used for JWT tokens validation (jks, pkcs12, etc.).", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "string", "javaType": "java.lang.String" },
- { "name": "camel.management.maxBodySize", "description": "Maximum HTTP body size the embedded HTTP server can accept.", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "integer", "javaType": "java.lang.Long" },
{ "name": "camel.management.metricsEnabled", "description": "Whether to enable metrics. If enabled then you can access metrics on context-path: \/q\/metrics (default)", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
{ "name": "camel.management.path", "description": "Context-path to use for embedded HTTP server", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "string", "javaType": "java.lang.String", "defaultValue": "\/" },
- { "name": "camel.management.port", "description": "Port to use for binding embedded HTTP server", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "integer", "javaType": "int", "defaultValue": 9876 },
+ { "name": "camel.management.port", "description": "Port to use for binding embedded HTTP server", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "integer", "javaType": "int", "defaultValue": 8080 },
{ "name": "camel.management.sendEnabled", "description": "Whether to enable sending messages to Camel via HTTP. This makes it possible to use Camel to send messages to Camel endpoint URIs via HTTP.", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
+ { "name": "camel.management.uploadEnabled", "description": "Whether to enable file upload via HTTP (not intended for production use). This functionality is for development to be able to reload Camel routes and code with source changes (if reload is enabled). If enabled then you can upload\/delete files via HTTP PUT\/DELETE on context-path: \/q\/upload\/{name}. You must also configure the uploadSourceDir option.", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationP [...]
+ { "name": "camel.management.uploadSourceDir", "description": "Source directory when upload is enabled.", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "string", "javaType": "java.lang.String" },
{ "name": "camel.management.useGlobalSslContextParameters", "description": "Whether to use global SSL configuration for securing the embedded HTTP server.", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
{ "name": "camel.metrics.baseEndpointURIExchangeEventNotifier", "description": "Whether to use static or dynamic values for Endpoint Name tags in captured metrics. By default, static values are used. When using dynamic tags, then a dynamic to (toD) can compute many different endpoint URIs that, can lead to many tags as the URI is dynamic, so use this with care if setting this option to false.", "sourceType": "org.apache.camel.main.MetricsConfigurationProperties", "type": "boolean", " [...]
{ "name": "camel.metrics.binders", "description": "Additional Micrometer binders to include such as jvm-memory, processor, jvm-thread, and so forth. Multiple binders can be separated by comma. The following binders currently is available from Micrometer: class-loader, commons-object-pool2, file-descriptor, hystrix-metrics-binder, jvm-compilation, jvm-gc, jvm-heap-pressure, jvm-info, jvm-memory, jvm-thread, log4j2, logback, processor, uptime", "sourceType": "org.apache.camel.main.Metr [...]
@@ -301,30 +303,19 @@
{ "name": "camel.server.authenticationEnabled", "description": "Whether to enable HTTP authentication for embedded server (for standalone applications; not Spring Boot or Quarkus).", "sourceType": "org.apache.camel.main.HttpServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
{ "name": "camel.server.authenticationPath", "description": "Set HTTP url path of embedded server that is protected by authentication configuration.", "sourceType": "org.apache.camel.main.HttpServerConfigurationProperties", "type": "string", "javaType": "java.lang.String" },
{ "name": "camel.server.basicPropertiesFile", "description": "Name of the file that contains basic authentication info for Vert.x file auth provider.", "sourceType": "org.apache.camel.main.HttpServerConfigurationProperties", "type": "string", "javaType": "java.lang.String" },
- { "name": "camel.server.devConsoleEnabled", "description": "Whether to enable developer console (not intended for production use). Dev console must also be enabled on CamelContext. For example by setting camel.context.dev-console=true in application.properties, or via code camelContext.setDevConsole(true); If enabled then you can access a basic developer console on context-path: \/q\/dev. Deprecated since 4.12.0, use HTTP management server instead.", "sourceType": "org.apache.camel.m [...]
- { "name": "camel.server.downloadEnabled", "description": "Whether to enable file download via HTTP. This makes it possible to browse and download resource source files such as Camel XML or YAML routes. Only enable this for development, troubleshooting or special situations for management and monitoring.", "sourceType": "org.apache.camel.main.HttpServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
{ "name": "camel.server.enabled", "description": "Whether embedded HTTP server is enabled. By default, the server is not enabled.", "sourceType": "org.apache.camel.main.HttpServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
{ "name": "camel.server.fileUploadDirectory", "description": "Directory to temporary store file uploads while Camel routes the incoming request. If no directory has been explicit configured, then a temporary directory is created in the java.io.tmpdir directory.", "sourceType": "org.apache.camel.main.HttpServerConfigurationProperties", "type": "string", "javaType": "java.lang.String" },
{ "name": "camel.server.fileUploadEnabled", "description": "Whether to enable file uploads being supported (such as POST multipart\/form-data) and stored into a temporary directory.", "sourceType": "org.apache.camel.main.HttpServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": true },
- { "name": "camel.server.healthCheckEnabled", "description": "Whether to enable health-check console. If enabled then you can access health-check status on context-path: \/q\/health (default). Deprecated since 4.12.0, use HTTP management server instead.", "sourceType": "org.apache.camel.main.HttpServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
- { "name": "camel.server.healthPath", "description": "The path endpoint used to expose the health status. Deprecated since 4.12.0, use HTTP management server instead.", "sourceType": "org.apache.camel.main.HttpServerConfigurationProperties", "type": "string", "javaType": "java.lang.String", "defaultValue": "\/q\/health" },
{ "name": "camel.server.host", "description": "Hostname to use for binding embedded HTTP server", "sourceType": "org.apache.camel.main.HttpServerConfigurationProperties", "type": "string", "javaType": "java.lang.String", "defaultValue": "0.0.0.0" },
- { "name": "camel.server.infoEnabled", "description": "Whether to enable info console. If enabled then you can see some basic Camel information at \/q\/info. Deprecated since 4.12.0, use HTTP management server instead.", "sourceType": "org.apache.camel.main.HttpServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
- { "name": "camel.server.jolokiaEnabled", "description": "Whether to enable jolokia. If enabled then you can access jolokia api on context-path: \/q\/jolokia. Deprecated since 4.12.0, use HTTP management server instead.", "sourceType": "org.apache.camel.main.HttpServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
- { "name": "camel.server.jolokiaPath", "description": "The path endpoint used to expose the jolokia data. Deprecated since 4.12.0, use HTTP management server instead.", "sourceType": "org.apache.camel.main.HttpServerConfigurationProperties", "type": "string", "javaType": "java.lang.String", "defaultValue": "\/q\/jolokia" },
{ "name": "camel.server.jwtKeystorePassword", "description": "Password from the keystore used for JWT tokens validation.", "sourceType": "org.apache.camel.main.HttpServerConfigurationProperties", "type": "string", "javaType": "java.lang.String" },
{ "name": "camel.server.jwtKeystorePath", "description": "Path to the keystore file used for JWT tokens validation.", "sourceType": "org.apache.camel.main.HttpServerConfigurationProperties", "type": "string", "javaType": "java.lang.String" },
{ "name": "camel.server.jwtKeystoreType", "description": "Type of the keystore used for JWT tokens validation (jks, pkcs12, etc.).", "sourceType": "org.apache.camel.main.HttpServerConfigurationProperties", "type": "string", "javaType": "java.lang.String" },
{ "name": "camel.server.maxBodySize", "description": "Maximum HTTP body size the embedded HTTP server can accept.", "sourceType": "org.apache.camel.main.HttpServerConfigurationProperties", "type": "integer", "javaType": "java.lang.Long" },
- { "name": "camel.server.metricsEnabled", "description": "Whether to enable metrics. If enabled then you can access metrics on context-path: \/q\/metrics (default). Deprecated since 4.12.0, use HTTP management server instead.", "sourceType": "org.apache.camel.main.HttpServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
{ "name": "camel.server.path", "description": "Context-path to use for embedded HTTP server", "sourceType": "org.apache.camel.main.HttpServerConfigurationProperties", "type": "string", "javaType": "java.lang.String", "defaultValue": "\/" },
{ "name": "camel.server.port", "description": "Port to use for binding embedded HTTP server", "sourceType": "org.apache.camel.main.HttpServerConfigurationProperties", "type": "integer", "javaType": "int", "defaultValue": 8080 },
- { "name": "camel.server.sendEnabled", "description": "Whether to enable sending messages to Camel via HTTP. This makes it possible to use Camel to send messages to Camel endpoint URIs via HTTP.", "sourceType": "org.apache.camel.main.HttpServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
{ "name": "camel.server.staticContextPath", "description": "The context-path to use for serving static content. By default, the root path is used. And if there is an index.html page then this is automatically loaded.", "sourceType": "org.apache.camel.main.HttpServerConfigurationProperties", "type": "string", "javaType": "java.lang.String", "defaultValue": "\/" },
{ "name": "camel.server.staticEnabled", "description": "Whether serving static files is enabled. If enabled then Camel can host html\/js and other web files that makes it possible to include small web applications.", "sourceType": "org.apache.camel.main.HttpServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
{ "name": "camel.server.staticSourceDir", "description": "Additional directory that holds static content when static is enabled.", "sourceType": "org.apache.camel.main.HttpServerConfigurationProperties", "type": "string", "javaType": "java.lang.String" },
- { "name": "camel.server.uploadEnabled", "description": "Whether to enable file upload via HTTP (not intended for production use). This functionality is for development to be able to reload Camel routes and code with source changes (if reload is enabled). If enabled then you can upload\/delete files via HTTP PUT\/DELETE on context-path: \/q\/upload\/{name}. You must also configure the uploadSourceDir option.", "sourceType": "org.apache.camel.main.HttpServerConfigurationProperties", "t [...]
- { "name": "camel.server.uploadSourceDir", "description": "Source directory when upload is enabled.", "sourceType": "org.apache.camel.main.HttpServerConfigurationProperties", "type": "string", "javaType": "java.lang.String" },
{ "name": "camel.server.useGlobalSslContextParameters", "description": "Whether to use global SSL configuration for securing the embedded HTTP server.", "sourceType": "org.apache.camel.main.HttpServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
{ "name": "camel.ssl.certAlias", "description": "An optional certificate alias to use. This is useful when the keystore has multiple certificates.", "sourceType": "org.apache.camel.main.SSLConfigurationProperties", "type": "string", "javaType": "java.lang.String" },
{ "name": "camel.ssl.cipherSuites", "description": "List of TLS\/SSL cipher suite algorithm names. Multiple names can be separated by comma.", "sourceType": "org.apache.camel.main.SSLConfigurationProperties", "type": "string", "javaType": "java.lang.String" },
diff --git a/components/camel-micrometer-prometheus/src/main/docs/micrometer-prometheus.adoc b/components/camel-micrometer-prometheus/src/main/docs/micrometer-prometheus.adoc
index 4ff9eea7f5b..eff9d29f96e 100644
--- a/components/camel-micrometer-prometheus/src/main/docs/micrometer-prometheus.adoc
+++ b/components/camel-micrometer-prometheus/src/main/docs/micrometer-prometheus.adoc
@@ -21,9 +21,9 @@ and turn on metrics in `application.properties` such as:
[source,properties]
----
-# enable HTTP server with metrics
-camel.server.enabled=true
-camel.server.metricsEnabled=true
+# enable management server with metrics
+camel.management.enabled=true
+camel.management.metricsEnabled=true
# turn on micrometer metrics
camel.metrics.enabled=true
diff --git a/components/camel-micrometer-prometheus/src/main/java/org/apache/camel/component/micrometer/prometheus/MicrometerPrometheus.java b/components/camel-micrometer-prometheus/src/main/java/org/apache/camel/component/micrometer/prometheus/MicrometerPrometheus.java
index adac6691298..c50402fd22a 100644
--- a/components/camel-micrometer-prometheus/src/main/java/org/apache/camel/component/micrometer/prometheus/MicrometerPrometheus.java
+++ b/components/camel-micrometer-prometheus/src/main/java/org/apache/camel/component/micrometer/prometheus/MicrometerPrometheus.java
@@ -50,7 +50,6 @@ import org.apache.camel.component.micrometer.routepolicy.MicrometerRoutePolicyFa
import org.apache.camel.component.micrometer.routepolicy.MicrometerRoutePolicyNamingStrategy;
import org.apache.camel.component.micrometer.spi.InstrumentedThreadPoolFactory;
import org.apache.camel.component.platform.http.PlatformHttpComponent;
-import org.apache.camel.component.platform.http.main.MainHttpServer;
import org.apache.camel.component.platform.http.main.ManagementHttpServer;
import org.apache.camel.component.platform.http.vertx.VertxPlatformHttpRouter;
import org.apache.camel.spi.CamelEvent;
@@ -77,14 +76,8 @@ public class MicrometerPrometheus extends ServiceSupport implements CamelMetrics
private static final String CONTENT_TYPE_004 = "text/plain; version=0.0.4; charset=utf-8";
private static final String CONTENT_TYPE_100 = "application/openmetrics-text; version=1.0.0; charset=utf-8";
- @Deprecated
- // Use managementServer instead
- private MainHttpServer mainServer;
- private ManagementHttpServer managementServer;
- @Deprecated
- // Use managementRouter instead
- private VertxPlatformHttpRouter mainRouter;
- private VertxPlatformHttpRouter managementRouter;
+ private ManagementHttpServer server;
+ private VertxPlatformHttpRouter router;
private PlatformHttpComponent platformHttpComponent;
private CamelContext camelContext;
@@ -426,24 +419,13 @@ public class MicrometerPrometheus extends ServiceSupport implements CamelMetrics
boolean enabled = false;
platformHttpComponent = camelContext.getComponent("platform-http", PlatformHttpComponent.class);
- mainServer = camelContext.hasService(MainHttpServer.class);
- if (mainServer != null && mainServer.isMetricsEnabled() && platformHttpComponent != null) {
- mainRouter = mainServer.getRouter();
- if (mainRouter != null) {
- setupHttpScraper(mainRouter, false);
- LOG.info("MicrometerPrometheus enabled with HTTP scraping on port {} on path {}",
- mainServer.getPort(), path);
- enabled = true;
- }
- }
-
- managementServer = camelContext.hasService(ManagementHttpServer.class);
- if (managementServer != null && managementServer.isMetricsEnabled() && platformHttpComponent != null) {
- managementRouter = managementServer.getRouter();
- if (managementRouter != null) {
- setupHttpScraper(managementRouter, true);
+ server = camelContext.hasService(ManagementHttpServer.class);
+ if (server != null && server.isMetricsEnabled() && platformHttpComponent != null) {
+ router = server.getRouter();
+ if (router != null) {
+ setupHttpScraper(router);
LOG.info("MicrometerPrometheus enabled with HTTP scraping on management port {} on path {}",
- managementServer.getPort(), path);
+ server.getPort(), path);
enabled = true;
}
}
@@ -480,7 +462,7 @@ public class MicrometerPrometheus extends ServiceSupport implements CamelMetrics
createdBinders.clear();
}
- protected void setupHttpScraper(VertxPlatformHttpRouter router, boolean isManagementPort) {
+ protected void setupHttpScraper(VertxPlatformHttpRouter router) {
Route metrics = router.route(path);
metrics.method(HttpMethod.GET);
@@ -507,12 +489,7 @@ public class MicrometerPrometheus extends ServiceSupport implements CamelMetrics
// use blocking handler as the task can take longer time to complete
metrics.handler(new BlockingHandlerDecorator(handler, true));
- if (isManagementPort) {
- platformHttpComponent.addHttpManagementEndpoint(path, "GET",
- null, format, null);
- } else {
- platformHttpComponent.addHttpEndpoint(path, "GET",
- null, format, null);
- }
+ platformHttpComponent.addHttpManagementEndpoint(path, "GET",
+ null, format, null);
}
}
diff --git a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_14.adoc b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_14.adoc
index 320b8b945e8..bdf69e0fe77 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_14.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_14.adoc
@@ -19,6 +19,13 @@ Previously, each sub-message was independent (despite the documentation refers t
has been mistakenly for many years, as this feature is rarely in use. However, we had the opportunity to look into this as part
of an issue, and felt it's better to fix this before for this LTS release.
+=== camel-main / camel-platform-http-main
+
+The HTTP server for standalone `camel-main` applications has separated management services and business services.
+This means that configurations should be changed from `camel.server.xxx` to `camel.management.xxx` as shown:
+
+TODO: list of options
+
=== camel-jbang
The `camel-jbang` has upgraded to Java 21 as the default java-version when running and exporting.
diff --git a/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/KameletMain.java b/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/KameletMain.java
index eea73658d0b..b1a33cf27d2 100644
--- a/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/KameletMain.java
+++ b/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/KameletMain.java
@@ -490,6 +490,7 @@ public class KameletMain extends MainCommandLineSupport {
if (silent) {
// silent should not include http server
configure().httpServer().withEnabled(false);
+ configure().httpManagementServer().withEnabled(false);
}
if (silent || "*".equals(stubPattern)) {
@@ -544,12 +545,12 @@ public class KameletMain extends MainCommandLineSupport {
boolean console = "true".equals(getInitialProperties().get(getInstanceType() + ".console"));
if (console) {
configure().setDevConsoleEnabled(true);
- configure().httpServer().withEnabled(true);
- configure().httpServer().withDevConsoleEnabled(true);
+ configure().httpManagementServer().withEnabled(true);
+ configure().httpManagementServer().withDevConsoleEnabled(true);
// also include health,info and jolokia
- configure().httpServer().withHealthCheckEnabled(true);
- configure().httpServer().withInfoEnabled(true);
- configure().httpServer().withJolokiaEnabled(true);
+ configure().httpManagementServer().withHealthCheckEnabled(true);
+ configure().httpManagementServer().withInfoEnabled(true);
+ configure().httpManagementServer().withJolokiaEnabled(true);
}
boolean tracing = "true".equals(getInitialProperties().get(getInstanceType() + ".backlogTracing"));
if (tracing) {
@@ -557,15 +558,15 @@ public class KameletMain extends MainCommandLineSupport {
}
boolean infoConsole = "true".equals(getInitialProperties().get(getInstanceType() + ".info"));
if (infoConsole) {
- configure().httpServer().withEnabled(true);
- configure().httpServer().withInfoEnabled(true);
+ configure().httpManagementServer().withEnabled(true);
+ configure().httpManagementServer().withInfoEnabled(true);
}
// Deprecated: to be replaced by observe flag
boolean health = "true".equals(getInitialProperties().get(getInstanceType() + ".health"));
if (health) {
configure().health().withEnabled(true);
- configure().httpServer().withEnabled(true);
- configure().httpServer().withHealthCheckEnabled(true);
+ configure().httpManagementServer().withEnabled(true);
+ configure().httpManagementServer().withHealthCheckEnabled(true);
}
// Deprecated: to be replaced by observe flag
boolean metrics = "true".equals(getInitialProperties().get(getInstanceType() + ".metrics"));
@@ -575,8 +576,8 @@ public class KameletMain extends MainCommandLineSupport {
.withEnableMessageHistory(true)
.withEnableExchangeEventNotifier(true)
.withEnableRoutePolicy(true).withEnabled(true);
- configure().httpServer().withEnabled(true);
- configure().httpServer().withMetricsEnabled(true);
+ configure().httpManagementServer().withEnabled(true);
+ configure().httpManagementServer().withMetricsEnabled(true);
}
boolean ignoreLoading = "true".equals(getInitialProperties().get(getInstanceType() + ".ignoreLoadingError"));
if (ignoreLoading) {
@@ -683,14 +684,15 @@ public class KameletMain extends MainCommandLineSupport {
// reloader
if (sourceDir != null) {
+ configure().httpServer().withEnabled(true);
configure().httpServer().withStaticSourceDir(sourceDir);
- configure().httpServer().withUploadSourceDir(sourceDir);
+ configure().httpManagementServer().withEnabled(true);
+ configure().httpManagementServer().withUploadSourceDir(sourceDir);
if (console || health) {
// allow to upload/download source (source-dir is intended to be dynamic) via http when HTTP console enabled
- configure().httpServer().withEnabled(true);
- configure().httpServer().withUploadEnabled(true);
- configure().httpServer().withDownloadEnabled(true);
+ configure().httpManagementServer().withUploadEnabled(true);
+ configure().httpManagementServer().withDownloadEnabled(true);
}
RouteOnDemandReloadStrategy reloader = new RouteOnDemandReloadStrategy(sourceDir, true);
reloader.setPattern("*");
(camel) 01/15: CAMEL-22285: platform-http-main - Dev consoles should be registered as management endpoints
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch man
in repository https://gitbox.apache.org/repos/asf/camel.git
commit bda8aa40f0c57dec27c9e608497af94f697f1446
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Jul 29 07:14:49 2025 +0200
CAMEL-22285: platform-http-main - Dev consoles should be registered as management endpoints
---
.../camel/component/platform/http/main/MainHttpServer.java | 7 ++++---
.../component/platform/http/main/ManagementHttpServer.java | 7 ++++---
.../src/main/java/org/apache/camel/main/BaseMainSupport.java | 12 ++++++------
3 files changed, 14 insertions(+), 12 deletions(-)
diff --git a/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/MainHttpServer.java b/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/MainHttpServer.java
index 049aad4dd4e..234cef965bd 100644
--- a/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/MainHttpServer.java
+++ b/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/MainHttpServer.java
@@ -787,9 +787,9 @@ public class MainHttpServer extends ServiceSupport implements CamelContextAware,
private static void healthCheckStatus(StringBuilder sb, boolean up) {
if (up) {
- sb.append(" \"status\": \"UP\"\n");
+ sb.append(" \"status\": \"UP\"");
} else {
- sb.append(" \"status\": \"DOWN\"\n");
+ sb.append(" \"status\": \"DOWN\"");
}
}
@@ -854,8 +854,9 @@ public class MainHttpServer extends ServiceSupport implements CamelContextAware,
}
sb.append("\n");
}
- sb.append(" }\n");
+ sb.append(" }");
}
+ sb.append("\n");
}
private static String allCausedByErrorMessages(Throwable e) {
diff --git a/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/ManagementHttpServer.java b/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/ManagementHttpServer.java
index d3f80dbbec1..9063452af11 100644
--- a/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/ManagementHttpServer.java
+++ b/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/ManagementHttpServer.java
@@ -630,9 +630,9 @@ public class ManagementHttpServer extends ServiceSupport implements CamelContext
private static void healthCheckStatus(StringBuilder sb, boolean up) {
if (up) {
- sb.append(" \"status\": \"UP\"\n");
+ sb.append(" \"status\": \"UP\"");
} else {
- sb.append(" \"status\": \"DOWN\"\n");
+ sb.append(" \"status\": \"DOWN\"");
}
}
@@ -697,8 +697,9 @@ public class ManagementHttpServer extends ServiceSupport implements CamelContext
}
sb.append("\n");
}
- sb.append(" }\n");
+ sb.append(" }");
}
+ sb.append("\n");
}
private static String allCausedByErrorMessages(Throwable e) {
diff --git a/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java b/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java
index 757ed18f023..1aa95e34c7b 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java
@@ -1444,12 +1444,6 @@ public abstract class BaseMainSupport extends BaseService {
mainConfigurationProperties.isAutoConfigurationFailFast(), true, autoConfiguredProperties);
camelContext.setRestConfiguration(rest);
}
- if (!httpServerProperties.isEmpty() || mainConfigurationProperties.hasHttpServerConfiguration()) {
- LOG.debug("Auto-configuring HTTP Server from loaded properties: {}", httpServerProperties.size());
- setHttpServerProperties(camelContext, httpServerProperties,
- mainConfigurationProperties.isAutoConfigurationFailFast(),
- autoConfiguredProperties);
- }
if (!httpManagementServerProperties.isEmpty() || mainConfigurationProperties.hasHttpManagementServerConfiguration()) {
LOG.debug("Auto-configuring HTTP Management Server from loaded properties: {}",
httpManagementServerProperties.size());
@@ -1457,6 +1451,12 @@ public abstract class BaseMainSupport extends BaseService {
mainConfigurationProperties.isAutoConfigurationFailFast(),
autoConfiguredProperties);
}
+ if (!httpServerProperties.isEmpty() || mainConfigurationProperties.hasHttpServerConfiguration()) {
+ LOG.debug("Auto-configuring HTTP Server from loaded properties: {}", httpServerProperties.size());
+ setHttpServerProperties(camelContext, httpServerProperties,
+ mainConfigurationProperties.isAutoConfigurationFailFast(),
+ autoConfiguredProperties);
+ }
if (!threadPoolProperties.isEmpty() || mainConfigurationProperties.hasThreadPoolConfiguration()) {
LOG.debug("Auto-configuring Thread Pool from loaded properties: {}", threadPoolProperties.size());
MainSupportModelConfigurer.setThreadPoolProperties(camelContext, mainConfigurationProperties, threadPoolProperties,
(camel) 15/15: CAMEL-22285: platform-http-main - Dev consoles should be registered as management endpoints
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch man
in repository https://gitbox.apache.org/repos/asf/camel.git
commit de32a10bb4aea232cf02425926cef826bcad43be
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Jul 29 20:35:09 2025 +0200
CAMEL-22285: platform-http-main - Dev consoles should be registered as management endpoints
---
.../apache/camel/dsl/jbang/core/commands/process/ListMetric.java | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/ListMetric.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/ListMetric.java
index b1d0fed4f08..66c891eeca4 100644
--- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/ListMetric.java
+++ b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/ListMetric.java
@@ -150,10 +150,14 @@ public class ListMetric extends ProcessWatchCommand {
JsonObject jo = (JsonObject) arr.get(i);
row.type = "gauge";
row.metricName = jo.getString("name");
+ if ("app.info".equals(row.metricName)) {
+ continue; // special camel info that hides in the metrics
+ }
row.metricDescription = jo.getString("description");
row.metricId = extractId(jo);
row.tags = extractTags(jo);
- row.count = jo.getDouble("value");
+ row.count = 0;
+ row.count = jo.getDoubleOrDefault("value", 0);
if (custom && row.metricName.startsWith("Camel")) {
continue; // skip internal camel metrics
(camel) 09/15: CAMEL-22285: platform-http-main - Dev consoles should be registered as management endpoints
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch man
in repository https://gitbox.apache.org/repos/asf/camel.git
commit d5ccecde4f7dd07dc9a754cfae059e24366a7906
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Jul 29 19:22:10 2025 +0200
CAMEL-22285: platform-http-main - Dev consoles should be registered as management endpoints
---
.../modules/ROOT/pages/camel-4x-upgrade-guide-4_14.adoc | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_14.adoc b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_14.adoc
index bdf69e0fe77..a146d39c59b 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_14.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_14.adoc
@@ -24,7 +24,18 @@ of an issue, and felt it's better to fix this before for this LTS release.
The HTTP server for standalone `camel-main` applications has separated management services and business services.
This means that configurations should be changed from `camel.server.xxx` to `camel.management.xxx` as shown:
-TODO: list of options
+
+|===
+|Old Option |New Option
+
+|Column 1, row 1
+|Column 2, row 1
+
+|Column 1, row 2
+|Column 2, row 2
+|===
+
+
=== camel-jbang
(camel) 05/15: CAMEL-22285: platform-http-main - Dev consoles should be registered as management endpoints
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch man
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 8fc7653ceda00f14eb7228b25305ea73aaf6b026
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Jul 29 16:01:37 2025 +0200
CAMEL-22285: platform-http-main - Dev consoles should be registered as management endpoints
---
.../http/main/DefaultMainHttpServerFactory.java | 19 +-
.../platform/http/main/MainHttpServer.java | 2 +
.../platform/http/main/ManagementHttpServer.java | 254 +++++++++++++++++++++
.../http/main/MainHttpFakeHealthCheck.java | 2 +-
.../http/main/MainHttpServerRouteTest.java | 1 -
...rverTest.java => ManagementHttpServerTest.java} | 5 +-
...entServerConfigurationPropertiesConfigurer.java | 21 ++
.../camel-main-configuration-metadata.json | 5 +-
core/camel-main/src/main/docs/main.adoc | 7 +-
.../org/apache/camel/main/BaseMainSupport.java | 12 +-
...ttpManagementServerConfigurationProperties.java | 74 +++++-
11 files changed, 372 insertions(+), 30 deletions(-)
diff --git a/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/DefaultMainHttpServerFactory.java b/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/DefaultMainHttpServerFactory.java
index faf85922e4f..0ae2a43f927 100644
--- a/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/DefaultMainHttpServerFactory.java
+++ b/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/DefaultMainHttpServerFactory.java
@@ -67,20 +67,9 @@ public class DefaultMainHttpServerFactory implements CamelContextAware, MainHttp
dir = TempDirHelper.resolveTempDir(camelContext, null, dir);
server.setFileUploadDirectory(dir);
}
- server.setInfoEnabled(configuration.isInfoEnabled());
server.setStaticEnabled(configuration.isStaticEnabled());
server.setStaticContextPath(configuration.getStaticContextPath());
server.setStaticSourceDir(configuration.getStaticSourceDir());
- server.setDevConsoleEnabled(configuration.isDevConsoleEnabled());
- server.setHealthCheckEnabled(configuration.isHealthCheckEnabled());
- server.setHealthPath(configuration.getHealthPath());
- server.setJolokiaEnabled(configuration.isJolokiaEnabled());
- server.setJolokiaPath(configuration.getJolokiaPath());
- server.setMetricsEnabled(configuration.isMetricsEnabled());
- server.setUploadEnabled(configuration.isUploadEnabled());
- server.setUploadSourceDir(configuration.getUploadSourceDir());
- server.setDownloadEnabled(configuration.isDownloadEnabled());
- server.setSendEnabled(configuration.isSendEnabled());
if (configuration.isAuthenticationEnabled()) {
configureAuthentication(server, configuration);
@@ -98,9 +87,7 @@ public class DefaultMainHttpServerFactory implements CamelContextAware, MainHttp
server.setHost(configuration.getHost());
server.setPort(configuration.getPort());
server.setPath(configuration.getPath());
- if (configuration.getMaxBodySize() != null) {
- server.setMaxBodySize(configuration.getMaxBodySize());
- }
+
server.setUseGlobalSslContextParameters(configuration.isUseGlobalSslContextParameters());
server.setInfoEnabled(configuration.isInfoEnabled());
server.setDevConsoleEnabled(configuration.isDevConsoleEnabled());
@@ -109,6 +96,10 @@ public class DefaultMainHttpServerFactory implements CamelContextAware, MainHttp
server.setJolokiaEnabled(configuration.isJolokiaEnabled());
server.setJolokiaPath(configuration.getJolokiaPath());
server.setMetricsEnabled(configuration.isMetricsEnabled());
+ server.setUploadEnabled(configuration.isUploadEnabled());
+ server.setUploadSourceDir(configuration.getUploadSourceDir());
+ server.setDownloadEnabled(configuration.isDownloadEnabled());
+ server.setSendEnabled(configuration.isSendEnabled());
if (configuration.isAuthenticationEnabled()) {
configureAuthentication(server, configuration);
diff --git a/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/MainHttpServer.java b/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/MainHttpServer.java
index d05de720fc9..e18de965004 100644
--- a/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/MainHttpServer.java
+++ b/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/MainHttpServer.java
@@ -38,6 +38,7 @@ import org.apache.camel.component.platform.http.vertx.VertxPlatformHttpServer;
import org.apache.camel.component.platform.http.vertx.VertxPlatformHttpServerConfiguration;
import org.apache.camel.support.ResolverHelper;
import org.apache.camel.support.jsse.SSLContextParameters;
+import org.apache.camel.support.service.ServiceHelper;
import org.apache.camel.support.service.ServiceSupport;
import org.apache.camel.util.FileUtil;
import org.apache.camel.util.IOHelper;
@@ -214,6 +215,7 @@ public class MainHttpServer extends ServiceSupport implements CamelContextAware,
@Override
protected void doStart() throws Exception {
ObjectHelper.notNull(camelContext, "CamelContext");
+ ServiceHelper.startService(server);
String routerName = VertxPlatformHttpRouter.getRouterNameFromPort(getPort());
router = VertxPlatformHttpRouter.lookup(camelContext, routerName);
platformHttpComponent = camelContext.getComponent("platform-http", PlatformHttpComponent.class);
diff --git a/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/ManagementHttpServer.java b/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/ManagementHttpServer.java
index 9b873b7f6d1..a4dc1104dbd 100644
--- a/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/ManagementHttpServer.java
+++ b/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/ManagementHttpServer.java
@@ -16,6 +16,9 @@
*/
package org.apache.camel.component.platform.http.main;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;
import java.util.ArrayList;
@@ -28,12 +31,14 @@ import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
+import java.util.StringJoiner;
import java.util.TreeSet;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import io.vertx.core.Handler;
import io.vertx.core.http.HttpMethod;
+import io.vertx.ext.web.RequestBody;
import io.vertx.ext.web.Route;
import io.vertx.ext.web.RoutingContext;
import io.vertx.ext.web.handler.BodyHandler;
@@ -64,15 +69,23 @@ import org.apache.camel.health.HealthCheckHelper;
import org.apache.camel.health.HealthCheckRegistry;
import org.apache.camel.http.base.HttpProtocolHeaderFilterStrategy;
import org.apache.camel.spi.HeaderFilterStrategy;
+import org.apache.camel.spi.PackageScanResourceResolver;
import org.apache.camel.spi.ReloadStrategy;
+import org.apache.camel.spi.Resource;
+import org.apache.camel.spi.ResourceLoader;
import org.apache.camel.support.CamelContextHelper;
import org.apache.camel.support.EndpointHelper;
import org.apache.camel.support.ExceptionHelper;
+import org.apache.camel.support.LoggerHelper;
import org.apache.camel.support.MessageHelper;
+import org.apache.camel.support.PluginHelper;
import org.apache.camel.support.ResolverHelper;
import org.apache.camel.support.jsse.SSLContextParameters;
import org.apache.camel.support.service.ServiceHelper;
import org.apache.camel.support.service.ServiceSupport;
+import org.apache.camel.util.AntPathMatcher;
+import org.apache.camel.util.FileUtil;
+import org.apache.camel.util.IOHelper;
import org.apache.camel.util.ObjectHelper;
import org.apache.camel.util.StopWatch;
import org.apache.camel.util.StringHelper;
@@ -110,6 +123,9 @@ public class ManagementHttpServer extends ServiceSupport implements CamelContext
private boolean metricsEnabled;
private String healthPath;
private String jolokiaPath;
+ private boolean uploadEnabled;
+ private String uploadSourceDir;
+ private boolean downloadEnabled;
private boolean sendEnabled;
@Override
@@ -282,6 +298,42 @@ public class ManagementHttpServer extends ServiceSupport implements CamelContext
configuration.setUseGlobalSslContextParameters(useGlobalSslContextParameters);
}
+ @ManagedAttribute(description = "Whether file upload is enabled (only for development) (q/upload)")
+ public boolean isUploadEnabled() {
+ return uploadEnabled;
+ }
+
+ /**
+ * Whether file upload is enabled (only for development) (q/upload)
+ */
+ public void setUploadEnabled(boolean uploadEnabled) {
+ this.uploadEnabled = uploadEnabled;
+ }
+
+ @ManagedAttribute(description = "Directory for upload.")
+ public String getUploadSourceDir() {
+ return uploadSourceDir;
+ }
+
+ /**
+ * Directory for upload.
+ */
+ public void setUploadSourceDir(String uploadSourceDir) {
+ this.uploadSourceDir = uploadSourceDir;
+ }
+
+ @ManagedAttribute(description = "Whether file download is enabled (q/download)")
+ public boolean isDownloadEnabled() {
+ return downloadEnabled;
+ }
+
+ /**
+ * Whether file download is enabled (q/download)
+ */
+ public void setDownloadEnabled(boolean downloadEnabled) {
+ this.downloadEnabled = downloadEnabled;
+ }
+
@ManagedAttribute(description = "Whether send message is enabled (q/send)")
public boolean isSendEnabled() {
return sendEnabled;
@@ -379,6 +431,15 @@ public class ManagementHttpServer extends ServiceSupport implements CamelContext
if (jolokiaEnabled) {
setupJolokia();
}
+ if (uploadEnabled) {
+ if (uploadSourceDir == null) {
+ throw new IllegalArgumentException("UploadSourceDir must be configured when uploadEnabled=true");
+ }
+ setupUploadConsole(uploadSourceDir);
+ }
+ if (downloadEnabled) {
+ setupDownloadConsole();
+ }
if (sendEnabled) {
setupSendConsole();
}
@@ -597,6 +658,199 @@ public class ManagementHttpServer extends ServiceSupport implements CamelContext
"text/plain,application/json", null);
}
+ protected void setupUploadConsole(final String dir) {
+ final Route upload = router.route("/q/upload/:filename")
+ .method(HttpMethod.PUT)
+ // need body handler to handle file uploads
+ .handler(BodyHandler.create(true));
+
+ final Route uploadDelete = router.route("/q/upload/:filename");
+ uploadDelete.method(HttpMethod.DELETE);
+
+ Handler<RoutingContext> handler = new Handler<RoutingContext>() {
+ @Override
+ public void handle(RoutingContext ctx) {
+ String name = ctx.pathParam("filename");
+ if (name == null) {
+ ctx.response().setStatusCode(400);
+ ctx.end();
+ return;
+ }
+
+ int status = 200;
+ boolean delete = HttpMethod.DELETE == ctx.request().method();
+ if (delete) {
+ if (name.contains("*")) {
+ if (name.equals("*")) {
+ name = "**";
+ }
+ AntPathMatcher match = AntPathMatcher.INSTANCE;
+ File[] files = new File(dir).listFiles();
+ if (files != null) {
+ for (File f : files) {
+ if (f.getName().startsWith(".") || f.isHidden()) {
+ continue;
+ }
+ if (match.match(name, f.getName())) {
+ LOG.info("Deleting file: {}/{}", dir, name);
+ FileUtil.deleteFile(f);
+ }
+ }
+ }
+ } else {
+ File f = new File(dir, name);
+ if (f.exists() && f.isFile()) {
+ LOG.info("Deleting file: {}/{}", dir, name);
+ FileUtil.deleteFile(f);
+ }
+ }
+ } else {
+ File f = new File(dir, name);
+ boolean exists = f.isFile() && f.exists();
+ LOG.info("{} file: {}/{}", exists ? "Updating" : "Creating", dir, name);
+
+ File tmp = new File(dir, name + ".tmp");
+ FileOutputStream fos = null;
+ try {
+ fos = new FileOutputStream(tmp, false);
+ RequestBody rb = ctx.body();
+ IOHelper.writeText(rb.asString(), fos);
+
+ FileUtil.renameFileUsingCopy(tmp, f);
+ FileUtil.deleteFile(tmp);
+ } catch (Exception e) {
+ // some kind of error
+ LOG.warn("Error saving file: {}/{} due to: {}", dir, name, e.getMessage(), e);
+ status = 500;
+ } finally {
+ IOHelper.close(fos);
+ FileUtil.deleteFile(tmp);
+ }
+ }
+
+ ctx.response().setStatusCode(status);
+ ctx.end();
+ }
+ };
+ // use blocking handler as the task can take longer time to complete
+ upload.handler(new BlockingHandlerDecorator(handler, true));
+ uploadDelete.handler(new BlockingHandlerDecorator(handler, true));
+
+ platformHttpComponent.addHttpManagementEndpoint("/q/upload", "PUT,DELETE",
+ "multipart/form-data", null, null);
+ }
+
+ protected void setupDownloadConsole() {
+ final Route download = router.route("/q/download/*")
+ .produces("text/plain")
+ .produces("application/octet-stream")
+ .method(HttpMethod.GET);
+
+ final AntPathMatcher matcher = AntPathMatcher.INSTANCE;
+ Handler<RoutingContext> handler = new Handler<RoutingContext>() {
+ @Override
+ public void handle(RoutingContext ctx) {
+ String name = StringHelper.after(ctx.normalizedPath(), "/q/download/");
+ boolean cp = "true".equals(ctx.queryParams().get("classpath"));
+ if (name == null || name.isBlank() || matcher.isPattern(name)) {
+ Set<String> names = new TreeSet<>();
+ if (cp) {
+ // also look inside classpath
+ PackageScanResourceResolver resolver = PluginHelper.getPackageScanResourceResolver(camelContext);
+ resolver.addClassLoader(camelContext.getApplicationContextClassLoader());
+ try {
+ String pattern = "**/*";
+ if (name != null && !name.isBlank()) {
+ pattern = "**/" + name;
+ }
+ for (Resource res : resolver.findResources(pattern)) {
+ String loc = res.getLocation();
+ loc = LoggerHelper.sourceNameOnly(loc);
+ names.add(loc);
+ }
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+ // always include routes
+ for (org.apache.camel.Route route : camelContext.getRoutes()) {
+ String loc = route.getSourceLocation();
+ if (loc != null) {
+ loc = LoggerHelper.sourceNameOnly(loc);
+ if (name == null || name.isBlank() || matcher.match(name, loc)) {
+ names.add(loc);
+ }
+ }
+ }
+
+ String acp = ctx.request().getHeader("Accept");
+ boolean html = acp != null && acp.contains("html");
+ StringJoiner sj;
+ if (html) {
+ String prefix = StringHelper.after(ctx.normalizedPath(), "/q/download/");
+ if (prefix == null) {
+ prefix = "/q/download/";
+ } else {
+ prefix = "";
+ }
+ ctx.response().putHeader("Content-Type", "text/html");
+ sj = new StringJoiner("<br/>");
+ for (String n : names) {
+ sj.add("<a href=" + prefix + n + ">" + n + "</a>");
+ }
+ } else {
+ ctx.response().putHeader("Content-Type", "text/plain");
+ sj = new StringJoiner("\n");
+ names.forEach(sj::add);
+ }
+ ctx.response().setStatusCode(200);
+ ctx.end(sj.toString());
+ } else {
+ // load file as resource (try both classpath and file)
+ ResourceLoader loader = PluginHelper.getResourceLoader(camelContext);
+ Resource res = loader.resolveResource("classpath:" + name);
+ if (res == null || !res.exists()) {
+ // attempt without path
+ res = loader.resolveResource("classpath:" + FileUtil.stripPath(name));
+ }
+ if (res == null || !res.exists()) {
+ for (org.apache.camel.Route route : camelContext.getRoutes()) {
+ String loc = route.getSourceLocation();
+ if (loc != null) {
+ loc = LoggerHelper.sourceNameOnly(loc);
+ if (matcher.match(name, loc)) {
+ res = route.getSourceResource();
+ break;
+ }
+ }
+ }
+ }
+ if (res != null && res.exists()) {
+ ctx.response().putHeader("Content-Type", "application/octet-stream");
+ ctx.response().putHeader("Content-Disposition",
+ "attachment; filename=\"" + FileUtil.stripPath(name) + "\"");
+ ctx.response().setStatusCode(200);
+ String data = null;
+ try {
+ data = IOHelper.loadText(res.getInputStream());
+ } catch (IOException e) {
+ // ignore
+ }
+ ctx.end(data);
+ } else {
+ ctx.response().setStatusCode(204);
+ ctx.end();
+ }
+ }
+ }
+ };
+ // use blocking handler as the task can take longer time to complete
+ download.handler(new BlockingHandlerDecorator(handler, true));
+
+ platformHttpComponent.addHttpManagementEndpoint("/q/download", "GET",
+ null, "text/plain,application/octet-stream", null);
+ }
+
protected void setupSendConsole() {
final Route send = router.route("/q/send/")
.produces("application/json")
diff --git a/components/camel-platform-http-main/src/test/java/org/apache/camel/component/platform/http/main/MainHttpFakeHealthCheck.java b/components/camel-platform-http-main/src/test/java/org/apache/camel/component/platform/http/main/MainHttpFakeHealthCheck.java
index 5165c1f0284..e63537c399e 100644
--- a/components/camel-platform-http-main/src/test/java/org/apache/camel/component/platform/http/main/MainHttpFakeHealthCheck.java
+++ b/components/camel-platform-http-main/src/test/java/org/apache/camel/component/platform/http/main/MainHttpFakeHealthCheck.java
@@ -14,7 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.camel.component.platform.http.main;
import java.util.Map;
@@ -23,6 +22,7 @@ import org.apache.camel.health.HealthCheckResultBuilder;
import org.apache.camel.impl.health.AbstractHealthCheck;
public class MainHttpFakeHealthCheck extends AbstractHealthCheck {
+
protected MainHttpFakeHealthCheck() {
super("camel", "consumer:fake");
}
diff --git a/components/camel-platform-http-main/src/test/java/org/apache/camel/component/platform/http/main/MainHttpServerRouteTest.java b/components/camel-platform-http-main/src/test/java/org/apache/camel/component/platform/http/main/MainHttpServerRouteTest.java
index 640ee0b0278..2998a7b3bca 100644
--- a/components/camel-platform-http-main/src/test/java/org/apache/camel/component/platform/http/main/MainHttpServerRouteTest.java
+++ b/components/camel-platform-http-main/src/test/java/org/apache/camel/component/platform/http/main/MainHttpServerRouteTest.java
@@ -14,7 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.camel.component.platform.http.main;
import java.net.URI;
diff --git a/components/camel-platform-http-main/src/test/java/org/apache/camel/component/platform/http/main/MainHttpServerTest.java b/components/camel-platform-http-main/src/test/java/org/apache/camel/component/platform/http/main/ManagementHttpServerTest.java
similarity index 95%
rename from components/camel-platform-http-main/src/test/java/org/apache/camel/component/platform/http/main/MainHttpServerTest.java
rename to components/camel-platform-http-main/src/test/java/org/apache/camel/component/platform/http/main/ManagementHttpServerTest.java
index 7c5a552079c..46600a4aeae 100644
--- a/components/camel-platform-http-main/src/test/java/org/apache/camel/component/platform/http/main/MainHttpServerTest.java
+++ b/components/camel-platform-http-main/src/test/java/org/apache/camel/component/platform/http/main/ManagementHttpServerTest.java
@@ -14,7 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.camel.component.platform.http.main;
import java.io.IOException;
@@ -30,7 +29,7 @@ import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
-class MainHttpServerTest {
+class ManagementHttpServerTest {
private CamelContext camelContext;
@@ -38,7 +37,7 @@ class MainHttpServerTest {
@Test
public void statusIsNotSatisfied() throws IOException, InterruptedException {
- MainHttpServer server = new MainHttpServer();
+ ManagementHttpServer server = new ManagementHttpServer();
camelContext = new DefaultCamelContext();
server.setCamelContext(camelContext);
diff --git a/core/camel-main/src/generated/java/org/apache/camel/main/HttpManagementServerConfigurationPropertiesConfigurer.java b/core/camel-main/src/generated/java/org/apache/camel/main/HttpManagementServerConfigurationPropertiesConfigurer.java
index a2f420a87d2..97418f57cfa 100644
--- a/core/camel-main/src/generated/java/org/apache/camel/main/HttpManagementServerConfigurationPropertiesConfigurer.java
+++ b/core/camel-main/src/generated/java/org/apache/camel/main/HttpManagementServerConfigurationPropertiesConfigurer.java
@@ -26,6 +26,7 @@ public class HttpManagementServerConfigurationPropertiesConfigurer extends org.a
map.put("AuthenticationPath", java.lang.String.class);
map.put("BasicPropertiesFile", java.lang.String.class);
map.put("DevConsoleEnabled", boolean.class);
+ map.put("DownloadEnabled", boolean.class);
map.put("Enabled", boolean.class);
map.put("HealthCheckEnabled", boolean.class);
map.put("HealthPath", java.lang.String.class);
@@ -40,6 +41,8 @@ public class HttpManagementServerConfigurationPropertiesConfigurer extends org.a
map.put("Path", java.lang.String.class);
map.put("Port", int.class);
map.put("SendEnabled", boolean.class);
+ map.put("UploadEnabled", boolean.class);
+ map.put("UploadSourceDir", java.lang.String.class);
map.put("UseGlobalSslContextParameters", boolean.class);
ALL_OPTIONS = map;
}
@@ -56,6 +59,8 @@ public class HttpManagementServerConfigurationPropertiesConfigurer extends org.a
case "basicPropertiesFile": target.setBasicPropertiesFile(property(camelContext, java.lang.String.class, value)); return true;
case "devconsoleenabled":
case "devConsoleEnabled": target.setDevConsoleEnabled(property(camelContext, boolean.class, value)); return true;
+ case "downloadenabled":
+ case "downloadEnabled": target.setDownloadEnabled(property(camelContext, boolean.class, value)); return true;
case "enabled": target.setEnabled(property(camelContext, boolean.class, value)); return true;
case "healthcheckenabled":
case "healthCheckEnabled": target.setHealthCheckEnabled(property(camelContext, boolean.class, value)); return true;
@@ -80,6 +85,10 @@ public class HttpManagementServerConfigurationPropertiesConfigurer extends org.a
case "port": target.setPort(property(camelContext, int.class, value)); return true;
case "sendenabled":
case "sendEnabled": target.setSendEnabled(property(camelContext, boolean.class, value)); return true;
+ case "uploadenabled":
+ case "uploadEnabled": target.setUploadEnabled(property(camelContext, boolean.class, value)); return true;
+ case "uploadsourcedir":
+ case "uploadSourceDir": target.setUploadSourceDir(property(camelContext, java.lang.String.class, value)); return true;
case "useglobalsslcontextparameters":
case "useGlobalSslContextParameters": target.setUseGlobalSslContextParameters(property(camelContext, boolean.class, value)); return true;
default: return false;
@@ -102,6 +111,8 @@ public class HttpManagementServerConfigurationPropertiesConfigurer extends org.a
case "basicPropertiesFile": return java.lang.String.class;
case "devconsoleenabled":
case "devConsoleEnabled": return boolean.class;
+ case "downloadenabled":
+ case "downloadEnabled": return boolean.class;
case "enabled": return boolean.class;
case "healthcheckenabled":
case "healthCheckEnabled": return boolean.class;
@@ -126,6 +137,10 @@ public class HttpManagementServerConfigurationPropertiesConfigurer extends org.a
case "port": return int.class;
case "sendenabled":
case "sendEnabled": return boolean.class;
+ case "uploadenabled":
+ case "uploadEnabled": return boolean.class;
+ case "uploadsourcedir":
+ case "uploadSourceDir": return java.lang.String.class;
case "useglobalsslcontextparameters":
case "useGlobalSslContextParameters": return boolean.class;
default: return null;
@@ -144,6 +159,8 @@ public class HttpManagementServerConfigurationPropertiesConfigurer extends org.a
case "basicPropertiesFile": return target.getBasicPropertiesFile();
case "devconsoleenabled":
case "devConsoleEnabled": return target.isDevConsoleEnabled();
+ case "downloadenabled":
+ case "downloadEnabled": return target.isDownloadEnabled();
case "enabled": return target.isEnabled();
case "healthcheckenabled":
case "healthCheckEnabled": return target.isHealthCheckEnabled();
@@ -168,6 +185,10 @@ public class HttpManagementServerConfigurationPropertiesConfigurer extends org.a
case "port": return target.getPort();
case "sendenabled":
case "sendEnabled": return target.isSendEnabled();
+ case "uploadenabled":
+ case "uploadEnabled": return target.isUploadEnabled();
+ case "uploadsourcedir":
+ case "uploadSourceDir": return target.getUploadSourceDir();
case "useglobalsslcontextparameters":
case "useGlobalSslContextParameters": return target.isUseGlobalSslContextParameters();
default: return null;
diff --git a/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json b/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json
index 0fe6ab967ee..66eff52bf6b 100644
--- a/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json
+++ b/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json
@@ -195,6 +195,7 @@
{ "name": "camel.management.authenticationPath", "description": "Set HTTP url path of embedded server that is protected by authentication configuration.", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "string", "javaType": "java.lang.String" },
{ "name": "camel.management.basicPropertiesFile", "description": "Name of the file that contains basic authentication info for Vert.x file auth provider.", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "string", "javaType": "java.lang.String" },
{ "name": "camel.management.devConsoleEnabled", "description": "Whether to enable developer console (not intended for production use). Dev console must also be enabled on CamelContext. For example by setting camel.context.dev-console=true in application.properties, or via code camelContext.setDevConsole(true); If enabled then you can access a basic developer console on context-path: \/q\/dev.", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": [...]
+ { "name": "camel.management.downloadEnabled", "description": "Whether to enable file download via HTTP. This makes it possible to browse and download resource source files such as Camel XML or YAML routes. Only enable this for development, troubleshooting or special situations for management and monitoring.", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
{ "name": "camel.management.enabled", "description": "Whether embedded HTTP server is enabled. By default, the server is not enabled.", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
{ "name": "camel.management.healthCheckEnabled", "description": "Whether to enable health-check console. If enabled then you can access health-check status on context-path: \/q\/health (default)", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
{ "name": "camel.management.healthPath", "description": "The path endpoint used to expose the health status", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "string", "javaType": "java.lang.String", "defaultValue": "\/observe\/health" },
@@ -207,8 +208,10 @@
{ "name": "camel.management.jwtKeystoreType", "description": "Type of the keystore used for JWT tokens validation (jks, pkcs12, etc.).", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "string", "javaType": "java.lang.String" },
{ "name": "camel.management.metricsEnabled", "description": "Whether to enable metrics. If enabled then you can access metrics on context-path: \/q\/metrics (default)", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
{ "name": "camel.management.path", "description": "Context-path to use for embedded HTTP server", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "string", "javaType": "java.lang.String", "defaultValue": "\/" },
- { "name": "camel.management.port", "description": "Port to use for binding embedded HTTP server", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "integer", "javaType": "int", "defaultValue": 9876 },
+ { "name": "camel.management.port", "description": "Port to use for binding embedded HTTP server", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "integer", "javaType": "int", "defaultValue": 8080 },
{ "name": "camel.management.sendEnabled", "description": "Whether to enable sending messages to Camel via HTTP. This makes it possible to use Camel to send messages to Camel endpoint URIs via HTTP.", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
+ { "name": "camel.management.uploadEnabled", "description": "Whether to enable file upload via HTTP (not intended for production use). This functionality is for development to be able to reload Camel routes and code with source changes (if reload is enabled). If enabled then you can upload\/delete files via HTTP PUT\/DELETE on context-path: \/q\/upload\/{name}. You must also configure the uploadSourceDir option.", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationP [...]
+ { "name": "camel.management.uploadSourceDir", "description": "Source directory when upload is enabled.", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "string", "javaType": "java.lang.String" },
{ "name": "camel.management.useGlobalSslContextParameters", "description": "Whether to use global SSL configuration for securing the embedded HTTP server.", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
{ "name": "camel.metrics.baseEndpointURIExchangeEventNotifier", "description": "Whether to use static or dynamic values for Endpoint Name tags in captured metrics. By default, static values are used. When using dynamic tags, then a dynamic to (toD) can compute many different endpoint URIs that, can lead to many tags as the URI is dynamic, so use this with care if setting this option to false.", "sourceType": "org.apache.camel.main.MetricsConfigurationProperties", "type": "boolean", " [...]
{ "name": "camel.metrics.binders", "description": "Additional Micrometer binders to include such as jvm-memory, processor, jvm-thread, and so forth. Multiple binders can be separated by comma. The following binders currently is available from Micrometer: class-loader, commons-object-pool2, file-descriptor, hystrix-metrics-binder, jvm-compilation, jvm-gc, jvm-heap-pressure, jvm-info, jvm-memory, jvm-thread, log4j2, logback, processor, uptime", "sourceType": "org.apache.camel.main.Metr [...]
diff --git a/core/camel-main/src/main/docs/main.adoc b/core/camel-main/src/main/docs/main.adoc
index f50aa19a745..fdeffb691d2 100644
--- a/core/camel-main/src/main/docs/main.adoc
+++ b/core/camel-main/src/main/docs/main.adoc
@@ -215,7 +215,7 @@ The camel.server supports 17 options, which are listed below.
=== Camel Embedded HTTP management Server (only for standalone; not Spring Boot or Quarkus) configurations
-The camel.management supports 19 options, which are listed below.
+The camel.management supports 22 options, which are listed below.
[width="100%",cols="2,5,^1,2",options="header"]
|===
@@ -224,6 +224,7 @@ The camel.management supports 19 options, which are listed below.
| *camel.management.authentication{zwsp}Path* | Set HTTP url path of embedded server that is protected by authentication configuration. | | String
| *camel.management.basic{zwsp}PropertiesFile* | Name of the file that contains basic authentication info for Vert.x file auth provider. | | String
| *camel.management.devConsole{zwsp}Enabled* | Whether to enable developer console (not intended for production use). Dev console must also be enabled on CamelContext. For example by setting camel.context.dev-console=true in application.properties, or via code camelContext.setDevConsole(true); If enabled then you can access a basic developer console on context-path: /q/dev. | false | boolean
+| *camel.management.download{zwsp}Enabled* | Whether to enable file download via HTTP. This makes it possible to browse and download resource source files such as Camel XML or YAML routes. Only enable this for development, troubleshooting or special situations for management and monitoring. | false | boolean
| *camel.management.enabled* | Whether embedded HTTP server is enabled. By default, the server is not enabled. | false | boolean
| *camel.management.healthCheck{zwsp}Enabled* | Whether to enable health-check console. If enabled then you can access health-check status on context-path: /q/health (default) | false | boolean
| *camel.management.healthPath* | The path endpoint used to expose the health status | /observe/health | String
@@ -236,8 +237,10 @@ The camel.management supports 19 options, which are listed below.
| *camel.management.jwtKeystore{zwsp}Type* | Type of the keystore used for JWT tokens validation (jks, pkcs12, etc.). | | String
| *camel.management.metrics{zwsp}Enabled* | Whether to enable metrics. If enabled then you can access metrics on context-path: /q/metrics (default) | false | boolean
| *camel.management.path* | Context-path to use for embedded HTTP server | / | String
-| *camel.management.port* | Port to use for binding embedded HTTP server | 9876 | int
+| *camel.management.port* | Port to use for binding embedded HTTP server | 8080 | int
| *camel.management.sendEnabled* | Whether to enable sending messages to Camel via HTTP. This makes it possible to use Camel to send messages to Camel endpoint URIs via HTTP. | false | boolean
+| *camel.management.uploadEnabled* | Whether to enable file upload via HTTP (not intended for production use). This functionality is for development to be able to reload Camel routes and code with source changes (if reload is enabled). If enabled then you can upload/delete files via HTTP PUT/DELETE on context-path: /q/upload/\{name}. You must also configure the uploadSourceDir option. | false | boolean
+| *camel.management.uploadSource{zwsp}Dir* | Source directory when upload is enabled. | | String
| *camel.management.useGlobalSsl{zwsp}ContextParameters* | Whether to use global SSL configuration for securing the embedded HTTP server. | false | boolean
|===
diff --git a/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java b/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java
index 1aa95e34c7b..757ed18f023 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java
@@ -1444,6 +1444,12 @@ public abstract class BaseMainSupport extends BaseService {
mainConfigurationProperties.isAutoConfigurationFailFast(), true, autoConfiguredProperties);
camelContext.setRestConfiguration(rest);
}
+ if (!httpServerProperties.isEmpty() || mainConfigurationProperties.hasHttpServerConfiguration()) {
+ LOG.debug("Auto-configuring HTTP Server from loaded properties: {}", httpServerProperties.size());
+ setHttpServerProperties(camelContext, httpServerProperties,
+ mainConfigurationProperties.isAutoConfigurationFailFast(),
+ autoConfiguredProperties);
+ }
if (!httpManagementServerProperties.isEmpty() || mainConfigurationProperties.hasHttpManagementServerConfiguration()) {
LOG.debug("Auto-configuring HTTP Management Server from loaded properties: {}",
httpManagementServerProperties.size());
@@ -1451,12 +1457,6 @@ public abstract class BaseMainSupport extends BaseService {
mainConfigurationProperties.isAutoConfigurationFailFast(),
autoConfiguredProperties);
}
- if (!httpServerProperties.isEmpty() || mainConfigurationProperties.hasHttpServerConfiguration()) {
- LOG.debug("Auto-configuring HTTP Server from loaded properties: {}", httpServerProperties.size());
- setHttpServerProperties(camelContext, httpServerProperties,
- mainConfigurationProperties.isAutoConfigurationFailFast(),
- autoConfiguredProperties);
- }
if (!threadPoolProperties.isEmpty() || mainConfigurationProperties.hasThreadPoolConfiguration()) {
LOG.debug("Auto-configuring Thread Pool from loaded properties: {}", threadPoolProperties.size());
MainSupportModelConfigurer.setThreadPoolProperties(camelContext, mainConfigurationProperties, threadPoolProperties,
diff --git a/core/camel-main/src/main/java/org/apache/camel/main/HttpManagementServerConfigurationProperties.java b/core/camel-main/src/main/java/org/apache/camel/main/HttpManagementServerConfigurationProperties.java
index a157c0e35a2..a18d01e078c 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/HttpManagementServerConfigurationProperties.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/HttpManagementServerConfigurationProperties.java
@@ -32,8 +32,8 @@ public class HttpManagementServerConfigurationProperties implements BootstrapClo
private boolean enabled;
@Metadata(defaultValue = "0.0.0.0")
private String host = "0.0.0.0";
- @Metadata(defaultValue = "9876")
- private int port = 9876;
+ @Metadata(defaultValue = "8080")
+ private int port = 8080;
@Metadata(defaultValue = "/")
private String path = "/";
@Metadata(defaultValue = "/observe/health")
@@ -46,6 +46,9 @@ public class HttpManagementServerConfigurationProperties implements BootstrapClo
private boolean healthCheckEnabled;
private boolean jolokiaEnabled;
private boolean metricsEnabled;
+ private boolean uploadEnabled;
+ private String uploadSourceDir;
+ private boolean downloadEnabled;
private boolean sendEnabled;
@Metadata(label = "security")
@@ -212,6 +215,44 @@ public class HttpManagementServerConfigurationProperties implements BootstrapClo
this.jolokiaPath = jolokiaPath;
}
+ public boolean isUploadEnabled() {
+ return uploadEnabled;
+ }
+
+ /**
+ * Whether to enable file upload via HTTP (not intended for production use). This functionality is for development
+ * to be able to reload Camel routes and code with source changes (if reload is enabled). If enabled then you can
+ * upload/delete files via HTTP PUT/DELETE on context-path: /q/upload/{name}. You must also configure the
+ * uploadSourceDir option.
+ */
+ public void setUploadEnabled(boolean uploadEnabled) {
+ this.uploadEnabled = uploadEnabled;
+ }
+
+ public String getUploadSourceDir() {
+ return uploadSourceDir;
+ }
+
+ /**
+ * Source directory when upload is enabled.
+ */
+ public void setUploadSourceDir(String uploadSourceDir) {
+ this.uploadSourceDir = uploadSourceDir;
+ }
+
+ public boolean isDownloadEnabled() {
+ return downloadEnabled;
+ }
+
+ /**
+ * Whether to enable file download via HTTP. This makes it possible to browse and download resource source files
+ * such as Camel XML or YAML routes. Only enable this for development, troubleshooting or special situations for
+ * management and monitoring.
+ */
+ public void setDownloadEnabled(boolean downloadEnabled) {
+ this.downloadEnabled = downloadEnabled;
+ }
+
public boolean isSendEnabled() {
return sendEnabled;
}
@@ -376,6 +417,35 @@ public class HttpManagementServerConfigurationProperties implements BootstrapClo
return this;
}
+ /**
+ * Whether to enable file upload via HTTP (not intended for production use). This functionality is for development
+ * to be able to reload Camel routes and code with source changes (if reload is enabled). If enabled then you can
+ * upload/delete files via HTTP PUT/DELETE on context-path: /q/upload/{name}. You must also configure the
+ * uploadSourceDir option.
+ */
+ public HttpManagementServerConfigurationProperties withUploadEnabled(boolean uploadEnabled) {
+ this.uploadEnabled = uploadEnabled;
+ return this;
+ }
+
+ /**
+ * Source directory when upload is enabled.
+ */
+ public HttpManagementServerConfigurationProperties withUploadSourceDir(String uploadSourceDir) {
+ this.uploadSourceDir = uploadSourceDir;
+ return this;
+ }
+
+ /**
+ * Whether to enable file download via HTTP. This makes it possible to browse and download resource source files
+ * such as Camel XML or YAML routes. Only enable this for development, troubleshooting or special situations for
+ * management and monitoring.
+ */
+ public HttpManagementServerConfigurationProperties withDownloadEnabled(boolean downloadEnabled) {
+ this.downloadEnabled = downloadEnabled;
+ return this;
+ }
+
/**
* Whether to enable sending messages to Camel via HTTP. This makes it possible to use Camel to send messages to
* Camel endpoint URIs via HTTP.
(camel) 10/15: CAMEL-22285: platform-http-main - Dev consoles should be registered as management endpoints
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch man
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 719be35048dc48c37057c0651cc16f717b2a7d4c
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Jul 29 19:28:52 2025 +0200
CAMEL-22285: platform-http-main - Dev consoles should be registered as management endpoints
---
.../ROOT/pages/camel-4x-upgrade-guide-4_14.adoc | 34 +++++++++++++++-------
1 file changed, 24 insertions(+), 10 deletions(-)
diff --git a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_14.adoc b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_14.adoc
index a146d39c59b..714cc383f04 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_14.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_14.adoc
@@ -19,23 +19,37 @@ Previously, each sub-message was independent (despite the documentation refers t
has been mistakenly for many years, as this feature is rarely in use. However, we had the opportunity to look into this as part
of an issue, and felt it's better to fix this before for this LTS release.
-=== camel-main / camel-platform-http-main
+=== camel-main
The HTTP server for standalone `camel-main` applications has separated management services and business services.
-This means that configurations should be changed from `camel.server.xxx` to `camel.management.xxx` as shown:
-
+This means that configurations in `application.properties` should be changed
+from `camel.server.xxx` to `camel.management.xxx` as shown below:
|===
-|Old Option |New Option
-
-|Column 1, row 1
-|Column 2, row 1
-
-|Column 1, row 2
-|Column 2, row 2
+|**Old Option** |**New Option**
+|camel.server.devConsoleEnabled | camel.management.devConsoleEnabled
+|camel.server.healthCheckEnabled | camel.management.healthCheckEnabled
+|camel.server.jolokiaEnabled | camel.management.jolokiaEnabled
+|camel.server.metricsEnabled | camel.management.metricsEnabled
+|camel.server.uploadEnabled | camel.management.uploadEnabled
+|camel.server.uploadSourceDir | camel.management.uploadSourceDir
+|camel.server.downloadEnabled | camel.management.downloadEnabled
+|camel.server.sendEnabled | camel.management.sendEnabled
+|camel.server.healthPath | camel.management.healthPath
+|camel.server.jolokiaPath | camel.management.jolokiaPath
|===
+NOTE: Make sure if you use any of the managed HTTP services such as health-checks then enable the management server with `camel.management.enabled=true`.
+The default HTTP endpoints has changed in some management services as listed below:
+
+|===
+|**Old Path** |**New Path**
+| /q/health | /observe/health
+| /q/metrics | /observe/metrics
+| /q/info | /observe/info
+| /q/jolokia | /observe/jolokia
+|===
=== camel-jbang
(camel) 03/15: CAMEL-22285: platform-http-main - Dev consoles should be registered as management endpoints
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch man
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 0008c53e5d7e5011aecebee8a228f6cf0a0cae39
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Jul 29 14:53:56 2025 +0200
CAMEL-22285: platform-http-main - Dev consoles should be registered as management endpoints
---
.../platform/http/main/MainHttpServer.java | 1092 --------------------
.../platform/http/main/ManagementHttpServer.java | 12 +-
2 files changed, 9 insertions(+), 1095 deletions(-)
diff --git a/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/MainHttpServer.java b/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/MainHttpServer.java
index 2d0c28182b8..d05de720fc9 100644
--- a/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/MainHttpServer.java
+++ b/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/MainHttpServer.java
@@ -18,82 +18,30 @@ package org.apache.camel.component.platform.http.main;
import java.io.File;
import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
import java.io.InputStream;
-import java.lang.management.ManagementFactory;
-import java.lang.management.RuntimeMXBean;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
import java.util.Optional;
-import java.util.Set;
-import java.util.StringJoiner;
-import java.util.TreeSet;
-import java.util.regex.Pattern;
-import java.util.stream.Collectors;
import io.vertx.core.Handler;
-import io.vertx.core.http.HttpMethod;
import io.vertx.core.http.impl.MimeMapping;
-import io.vertx.ext.web.RequestBody;
import io.vertx.ext.web.Route;
import io.vertx.ext.web.RoutingContext;
-import io.vertx.ext.web.handler.BodyHandler;
import io.vertx.ext.web.impl.BlockingHandlerDecorator;
import org.apache.camel.CamelContext;
import org.apache.camel.CamelContextAware;
-import org.apache.camel.ConsumerTemplate;
-import org.apache.camel.Endpoint;
-import org.apache.camel.Exchange;
-import org.apache.camel.ExchangePattern;
-import org.apache.camel.NoSuchEndpointException;
-import org.apache.camel.ProducerTemplate;
import org.apache.camel.StaticService;
import org.apache.camel.api.management.ManagedAttribute;
-import org.apache.camel.api.management.ManagedCamelContext;
import org.apache.camel.api.management.ManagedResource;
-import org.apache.camel.api.management.mbean.ManagedCamelContextMBean;
import org.apache.camel.component.platform.http.PlatformHttpComponent;
-import org.apache.camel.component.platform.http.plugin.JolokiaPlatformHttpPlugin;
import org.apache.camel.component.platform.http.spi.PlatformHttpPluginRegistry;
import org.apache.camel.component.platform.http.vertx.VertxPlatformHttpRouter;
import org.apache.camel.component.platform.http.vertx.VertxPlatformHttpServer;
import org.apache.camel.component.platform.http.vertx.VertxPlatformHttpServerConfiguration;
-import org.apache.camel.console.DevConsole;
-import org.apache.camel.console.DevConsoleRegistry;
-import org.apache.camel.health.HealthCheck;
-import org.apache.camel.health.HealthCheckHelper;
-import org.apache.camel.health.HealthCheckRegistry;
-import org.apache.camel.http.base.HttpProtocolHeaderFilterStrategy;
-import org.apache.camel.spi.HeaderFilterStrategy;
-import org.apache.camel.spi.PackageScanResourceResolver;
-import org.apache.camel.spi.ReloadStrategy;
-import org.apache.camel.spi.Resource;
-import org.apache.camel.spi.ResourceLoader;
-import org.apache.camel.support.CamelContextHelper;
-import org.apache.camel.support.EndpointHelper;
-import org.apache.camel.support.ExceptionHelper;
-import org.apache.camel.support.LoggerHelper;
-import org.apache.camel.support.MessageHelper;
-import org.apache.camel.support.PluginHelper;
import org.apache.camel.support.ResolverHelper;
import org.apache.camel.support.jsse.SSLContextParameters;
-import org.apache.camel.support.service.ServiceHelper;
import org.apache.camel.support.service.ServiceSupport;
-import org.apache.camel.util.AntPathMatcher;
import org.apache.camel.util.FileUtil;
import org.apache.camel.util.IOHelper;
import org.apache.camel.util.ObjectHelper;
-import org.apache.camel.util.StopWatch;
-import org.apache.camel.util.StringHelper;
-import org.apache.camel.util.TimeUtils;
-import org.apache.camel.util.json.JsonObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -101,43 +49,17 @@ import org.slf4j.LoggerFactory;
public class MainHttpServer extends ServiceSupport implements CamelContextAware, StaticService {
private static final Logger LOG = LoggerFactory.getLogger(MainHttpServer.class);
- private static final int BODY_MAX_CHARS = 128 * 1024;
- private static final int DEFAULT_POLL_TIMEOUT = 20000;
-
- private final HeaderFilterStrategy filter = new HttpProtocolHeaderFilterStrategy();
- private ProducerTemplate producer;
- private ConsumerTemplate consumer;
private VertxPlatformHttpServer server;
private VertxPlatformHttpRouter router;
private CamelContext camelContext;
private PlatformHttpComponent platformHttpComponent;
- private PlatformHttpPluginRegistry pluginRegistry;
- private JolokiaPlatformHttpPlugin jolokiaPlugin;
private VertxPlatformHttpServerConfiguration configuration = new VertxPlatformHttpServerConfiguration();
- @Deprecated(since = "4.12.0")
- private boolean infoEnabled;
private boolean staticEnabled;
private String staticSourceDir;
private String staticContextPath;
- @Deprecated(since = "4.12.0")
- private boolean devConsoleEnabled;
- @Deprecated(since = "4.12.0")
- private boolean healthCheckEnabled;
- @Deprecated(since = "4.12.0")
- private boolean jolokiaEnabled;
- @Deprecated(since = "4.12.0")
- private boolean metricsEnabled;
- private boolean uploadEnabled;
- private String uploadSourceDir;
- private boolean downloadEnabled;
- private boolean sendEnabled;
- @Deprecated(since = "4.12.0")
- private String healthPath;
- @Deprecated(since = "4.12.0")
- private String jolokiaPath;
@Override
public CamelContext getCamelContext() {
@@ -175,19 +97,6 @@ public class MainHttpServer extends ServiceSupport implements CamelContextAware,
configuration.getBodyHandler().setUploadsDirectory(fileUploadDirectory);
}
- @ManagedAttribute(description = "Whether info is enabled")
- @Deprecated(since = "4.12.0")
- public boolean isInfoEnabled() {
- return infoEnabled;
- }
-
- /**
- * Deprecated: use ManagementHttpServer instead.
- */
- public void setInfoEnabled(boolean infoEnabled) {
- this.infoEnabled = infoEnabled;
- }
-
@ManagedAttribute(description = "Whether serving static content is enabled (such as html pages)")
public boolean isStaticEnabled() {
return staticEnabled;
@@ -220,131 +129,6 @@ public class MainHttpServer extends ServiceSupport implements CamelContextAware,
return staticEnabled;
}
- @ManagedAttribute(description = "Whether dev console is enabled")
- @Deprecated(since = "4.12.0")
- public boolean isDevConsoleEnabled() {
- return devConsoleEnabled;
- }
-
- /**
- * Whether developer web console is enabled (q/dev). Deprecated: use ManagementHttpServer instead.
- */
- public void setDevConsoleEnabled(boolean devConsoleEnabled) {
- this.devConsoleEnabled = devConsoleEnabled;
- }
-
- @ManagedAttribute(description = "Whether health check is enabled")
- @Deprecated(since = "4.12.0")
- public boolean isHealthCheckEnabled() {
- return healthCheckEnabled;
- }
-
- @ManagedAttribute(description = "Whether Jolokia is enabled")
- @Deprecated(since = "4.12.0")
- public boolean isJolokiaEnabled() {
- return jolokiaEnabled;
- }
-
- /**
- * Whether health-check is enabled (q/health). Deprecated: use ManagementHttpServer instead.
- */
- public void setHealthCheckEnabled(boolean healthCheckEnabled) {
- this.healthCheckEnabled = healthCheckEnabled;
- }
-
- /**
- * Whether jolokia is enabled (q/jolokia). Deprecated: use ManagementHttpServer instead.
- */
- public void setJolokiaEnabled(boolean jolokiaEnabledEnabled) {
- this.jolokiaEnabled = jolokiaEnabledEnabled;
- }
-
- @ManagedAttribute(description = "The context-path for serving health check status")
- @Deprecated(since = "4.12.0")
- public String getHealthPath() {
- return healthPath;
- }
-
- /**
- * The path endpoint used to expose the health status. Deprecated: use ManagementHttpServer instead.
- */
- public void setHealthPath(String healthPath) {
- this.healthPath = healthPath;
- }
-
- @ManagedAttribute(description = "The context-path for serving Jolokia data")
- public String getJolokiaPath() {
- return jolokiaPath;
- }
-
- /**
- * The path endpoint used to expose the Jolokia data.
- */
- public void setJolokiaPath(String jolokiaPath) {
- this.jolokiaPath = jolokiaPath;
- }
-
- @ManagedAttribute(description = "Whether metrics is enabled")
- public boolean isMetricsEnabled() {
- return metricsEnabled;
- }
-
- /**
- * Whether metrics is enabled (q/metrics)
- */
- public void setMetricsEnabled(boolean metricsEnabled) {
- this.metricsEnabled = metricsEnabled;
- }
-
- @ManagedAttribute(description = "Whether file upload is enabled (only for development)")
- public boolean isUploadEnabled() {
- return uploadEnabled;
- }
-
- /**
- * Whether file upload is enabled (only for development) (q/upload)
- */
- public void setUploadEnabled(boolean uploadEnabled) {
- this.uploadEnabled = uploadEnabled;
- }
-
- @ManagedAttribute(description = "Directory for upload.")
- public String getUploadSourceDir() {
- return uploadSourceDir;
- }
-
- /**
- * Directory for upload.
- */
- public void setUploadSourceDir(String uploadSourceDir) {
- this.uploadSourceDir = uploadSourceDir;
- }
-
- @ManagedAttribute(description = "Whether file download is enabled")
- public boolean isDownloadEnabled() {
- return downloadEnabled;
- }
-
- /**
- * Whether file download is enabled (q/download)
- */
- public void setDownloadEnabled(boolean downloadEnabled) {
- this.downloadEnabled = downloadEnabled;
- }
-
- @ManagedAttribute(description = "Whether send message is enabled")
- public boolean isSendEnabled() {
- return sendEnabled;
- }
-
- /**
- * Whether to enable sending messages to Camel via HTTP. This makes it possible to use Camel to send messages to
- * Camel endpoint URIs via HTTP.
- */
- public void setSendEnabled(boolean sendEnabled) {
- this.sendEnabled = sendEnabled;
- }
-
@ManagedAttribute(description = "HTTP server port number")
public int getPort() {
return configuration.getBindPort();
@@ -422,30 +206,14 @@ public class MainHttpServer extends ServiceSupport implements CamelContextAware,
protected void doInit() throws Exception {
ObjectHelper.notNull(camelContext, "CamelContext");
- if (sendEnabled && producer == null) {
- producer = camelContext.createProducerTemplate();
- }
- if (sendEnabled && consumer == null) {
- consumer = camelContext.createConsumerTemplate();
- }
-
server = new VertxPlatformHttpServer(configuration);
// adding server to camel-context which will manage shutdown the server, so we should not do this here
camelContext.addService(server);
-
- pluginRegistry = getCamelContext().getCamelContextExtension().getContextPlugin(PlatformHttpPluginRegistry.class);
- if (pluginRegistry == null && pluginsEnabled()) {
- pluginRegistry = resolvePlatformHttpPluginRegistry();
- pluginRegistry.setCamelContext(getCamelContext());
- getCamelContext().getCamelContextExtension().addContextPlugin(PlatformHttpPluginRegistry.class, pluginRegistry);
- }
- ServiceHelper.initService(pluginRegistry, producer, consumer);
}
@Override
protected void doStart() throws Exception {
ObjectHelper.notNull(camelContext, "CamelContext");
- ServiceHelper.startService(server, pluginRegistry, producer, consumer);
String routerName = VertxPlatformHttpRouter.getRouterNameFromPort(getPort());
router = VertxPlatformHttpRouter.lookup(camelContext, routerName);
platformHttpComponent = camelContext.getComponent("platform-http", PlatformHttpComponent.class);
@@ -454,44 +222,10 @@ public class MainHttpServer extends ServiceSupport implements CamelContextAware,
setupStartupSummary();
}
- @Override
- protected void doShutdown() throws Exception {
- ServiceHelper.stopAndShutdownServices(pluginRegistry, producer, consumer);
- }
-
- private boolean pluginsEnabled() {
- return jolokiaEnabled;
- }
-
protected void setupConsoles() {
- if (infoEnabled) {
- setupInfo();
- }
if (staticEnabled) {
setupStatic();
}
- if (devConsoleEnabled) {
- setupDevConsole();
- }
- if (healthCheckEnabled) {
- setupHealthCheckConsole();
- }
- if (jolokiaEnabled) {
- setupJolokia();
- }
- if (uploadEnabled) {
- if (uploadSourceDir == null) {
- throw new IllegalArgumentException("UploadSourceDir must be configured when uploadEnabled=true");
- }
- setupUploadConsole(uploadSourceDir);
- }
- if (downloadEnabled) {
- setupDownloadConsole();
- }
- if (sendEnabled) {
- setupSendConsole();
- }
- // metrics will be setup in camel-micrometer-prometheus
}
protected void setupStatic() {
@@ -564,218 +298,6 @@ public class MainHttpServer extends ServiceSupport implements CamelContextAware,
platformHttpComponent.addHttpEndpoint(staticContextPath, null, null, null, null);
}
- protected void setupInfo() {
- final Route info = router.route("/q/info");
- info.method(HttpMethod.GET);
- info.produces("application/json");
-
- Handler<RoutingContext> handler = new Handler<RoutingContext>() {
-
- private String extractState(int status) {
- if (status <= 4) {
- return "Starting";
- } else if (status == 5) {
- return "Running";
- } else if (status == 6) {
- return "Suspending";
- } else if (status == 7) {
- return "Suspended";
- } else if (status == 8) {
- return "Terminating";
- } else if (status == 9) {
- return "Terminated";
- } else {
- return "Terminated";
- }
- }
-
- @Override
- public void handle(RoutingContext ctx) {
- ctx.response().putHeader("content-type", "application/json");
-
- JsonObject root = new JsonObject();
-
- JsonObject jo = new JsonObject();
- root.put("os", jo);
- jo.put("name", System.getProperty("os.name"));
- jo.put("version", System.getProperty("os.version"));
- jo.put("arch", System.getProperty("os.arch"));
-
- jo = new JsonObject();
- root.put("java", jo);
- RuntimeMXBean rmb = ManagementFactory.getRuntimeMXBean();
- if (rmb != null) {
- jo.put("pid", rmb.getPid());
- jo.put("vendor", rmb.getVmVendor());
- jo.put("name", rmb.getVmName());
- jo.put("vmVersion", rmb.getVmVersion());
- jo.put("version", String.format("%s", System.getProperty("java.version")));
- jo.put("user", System.getProperty("user.name"));
- jo.put("dir", System.getProperty("user.dir"));
- jo.put("home", System.getProperty("user.home"));
- }
-
- jo = new JsonObject();
- root.put("camel", jo);
- jo.put("name", camelContext.getName());
- jo.put("version", camelContext.getVersion());
- if (camelContext.getCamelContextExtension().getProfile() != null) {
- jo.put("profile", camelContext.getCamelContextExtension().getProfile());
- }
- if (camelContext.getCamelContextExtension().getDescription() != null) {
- jo.put("description", camelContext.getCamelContextExtension().getDescription());
- }
- Collection<HealthCheck.Result> results = HealthCheckHelper.invoke(getCamelContext());
- boolean up = results.stream().allMatch(h -> HealthCheck.State.UP.equals(h.getState()));
- jo.put("ready", up ? "1/1" : "0/1");
- jo.put("status", extractState(getCamelContext().getCamelContextExtension().getStatusPhase()));
- int reloaded = 0;
- Set<ReloadStrategy> rs = getCamelContext().hasServices(ReloadStrategy.class);
- for (ReloadStrategy r : rs) {
- reloaded += r.getReloadCounter();
- }
- jo.put("reload", reloaded);
- jo.put("age", CamelContextHelper.getUptime(camelContext));
-
- ManagedCamelContext mcc
- = getCamelContext().getCamelContextExtension().getContextPlugin(ManagedCamelContext.class);
- if (mcc != null) {
- ManagedCamelContextMBean mb = mcc.getManagedCamelContext();
-
- long total = camelContext.getRoutes().stream()
- .filter(r -> !r.isCreatedByRestDsl() && !r.isCreatedByKamelet()).count();
- long started = camelContext.getRoutes().stream()
- .filter(r -> !r.isCreatedByRestDsl() && !r.isCreatedByKamelet())
- .filter(ServiceHelper::isStarted).count();
- jo.put("routes", started + "/" + total);
- String thp = mb.getThroughput();
- thp = thp.replace(',', '.');
- if (!thp.isEmpty()) {
- jo.put("exchangesThroughput", thp + "/s");
- }
- jo.put("exchangesTotal", mb.getExchangesTotal());
- jo.put("exchangesFailed", mb.getExchangesFailed());
- jo.put("exchangesInflight", mb.getExchangesInflight());
- if (mb.getExchangesTotal() > 0) {
- jo.put("lastProcessingTime", mb.getLastProcessingTime());
- jo.put("deltaProcessingTime", mb.getDeltaProcessingTime());
- }
- Date last = mb.getLastExchangeCreatedTimestamp();
- if (last != null) {
- jo.put("sinceLastExchangeCreated", TimeUtils.printSince(last.getTime()));
- }
- last = mb.getLastExchangeFailureTimestamp();
- if (last != null) {
- jo.put("sinceLastExchangeFailed", TimeUtils.printSince(last.getTime()));
- }
- last = mb.getLastExchangeCompletedTimestamp();
- if (last != null) {
- jo.put("sinceLastExchangeCompleted", TimeUtils.printSince(last.getTime()));
- }
- }
-
- ctx.end(root.toJson());
- }
- };
-
- // use blocking handler as the task can take longer time to complete
- info.handler(new BlockingHandlerDecorator(handler, true));
-
- platformHttpComponent.addHttpEndpoint("/q/info", "GET", null,
- "application/json", null);
- }
-
- protected void setupHealthCheckConsole() {
- final Route health = router.route(this.healthPath);
- health.method(HttpMethod.GET);
- health.produces("application/json");
- final Route live = router.route(this.healthPath + "/live");
- live.method(HttpMethod.GET);
- live.produces("application/json");
- final Route ready = router.route(this.healthPath + "/ready");
- ready.method(HttpMethod.GET);
- ready.produces("application/json");
-
- Handler<RoutingContext> handler = new Handler<RoutingContext>() {
- @Override
- public void handle(RoutingContext ctx) {
- ctx.response().putHeader("content-type", "application/json");
-
- HealthCheckRegistry registry = HealthCheckRegistry.get(camelContext);
- String level = ctx.request().getParam("exposureLevel");
- if (level == null) {
- level = registry.getExposureLevel();
- }
- String includeStackTrace = ctx.request().getParam("stackTrace");
- String includeData = ctx.request().getParam("data");
-
- boolean all = ctx.currentRoute() == health;
- boolean liv = ctx.currentRoute() == live;
- boolean rdy = ctx.currentRoute() == ready;
-
- Collection<HealthCheck.Result> res;
- if (all) {
- res = HealthCheckHelper.invoke(camelContext, level);
- } else if (liv) {
- res = HealthCheckHelper.invokeLiveness(camelContext, level);
- } else {
- res = HealthCheckHelper.invokeReadiness(camelContext, level);
- }
-
- StringBuilder sb = new StringBuilder();
- sb.append("{\n");
-
- // are we UP
- boolean up = HealthCheckHelper.isResultsUp(res, rdy);
-
- if ("oneline".equals(level)) {
- // only brief status
- healthCheckStatus(sb, up);
- } else if ("full".equals(level)) {
- // include all details
- List<HealthCheck.Result> list = new ArrayList<>(res);
- healthCheckDetails(sb, list, up, level, includeStackTrace, includeData);
- } else {
- // include only DOWN details
- List<HealthCheck.Result> downs = res.stream().filter(r -> r.getState().equals(HealthCheck.State.DOWN))
- .collect(Collectors.toList());
- healthCheckDetails(sb, downs, up, level, includeStackTrace, includeData);
- }
- sb.append("}\n");
-
- if (!up) {
- // we need to fail with a http status so lets use 500
- ctx.response().setStatusCode(503);
- }
- ctx.end(sb.toString());
- }
- };
- // use blocking handler as the task can take longer time to complete
- health.handler(new BlockingHandlerDecorator(handler, true));
- live.handler(new BlockingHandlerDecorator(handler, true));
- ready.handler(new BlockingHandlerDecorator(handler, true));
-
- platformHttpComponent.addHttpEndpoint(this.healthPath, "GET", null,
- "application/json", null);
- }
-
- protected void setupJolokia() {
- // load plugin
- jolokiaPlugin = pluginRegistry.resolvePluginById(JolokiaPlatformHttpPlugin.NAME, JolokiaPlatformHttpPlugin.class)
- .orElseThrow(() -> new RuntimeException(
- "JolokiaPlatformHttpPlugin not found. Please add camel-platform-http-jolokia dependency."));
-
- Route jolokia = router.route(jolokiaPath + "/*");
- jolokia.method(HttpMethod.GET);
- jolokia.method(HttpMethod.POST);
-
- Handler<RoutingContext> handler = (Handler<RoutingContext>) jolokiaPlugin.getHandler();
- jolokia.handler(new BlockingHandlerDecorator(handler, true));
-
- platformHttpComponent.addHttpEndpoint(jolokiaPath, "GET,POST", null,
- "application/json", null);
- }
-
protected PlatformHttpPluginRegistry resolvePlatformHttpPluginRegistry() {
Optional<PlatformHttpPluginRegistry> result = ResolverHelper.resolveService(
getCamelContext(),
@@ -785,620 +307,6 @@ public class MainHttpServer extends ServiceSupport implements CamelContextAware,
"Cannot create PlatformHttpPluginRegistry. Make sure camel-platform-http JAR is on classpath."));
}
- private static void healthCheckStatus(StringBuilder sb, boolean up) {
- if (up) {
- sb.append(" \"status\": \"UP\"");
- } else {
- sb.append(" \"status\": \"DOWN\"");
- }
- }
-
- private static void healthCheckDetails(
- StringBuilder sb, List<HealthCheck.Result> checks, boolean up, String level, String includeStackTrace,
- String includeData) {
- healthCheckStatus(sb, up);
-
- if (!checks.isEmpty()) {
- sb.append(",\n");
- sb.append(" \"checks\": [\n");
- for (int i = 0; i < checks.size(); i++) {
- HealthCheck.Result d = checks.get(i);
- sb.append(" {\n");
- reportHealthCheck(sb, d, level, includeStackTrace, includeData);
- if (i < checks.size() - 1) {
- sb.append(" },\n");
- } else {
- sb.append(" }\n");
- }
- }
- sb.append(" ]\n");
- }
- }
-
- private static void reportHealthCheck(
- StringBuilder sb, HealthCheck.Result d, String level, String includeStackTrace, String includeData) {
- sb.append(" \"name\": \"").append(d.getCheck().getId()).append("\",\n");
- sb.append(" \"status\": \"").append(d.getState()).append("\"");
- if (("full".equals(level) || "true".equals(includeStackTrace)) && d.getError().isPresent()) {
- // include error message in full exposure
- sb.append(",\n");
- String msg = allCausedByErrorMessages(d.getError().get());
- sb.append(" \"error-message\": \"").append(msg)
- .append("\"");
- if ("true".equals(includeStackTrace)) {
- sb.append(",\n");
- sb.append(" \"error-stacktrace\": \"").append(errorStackTrace(d.getError().get()))
- .append("\"");
- }
- }
- if (d.getMessage().isPresent()) {
- sb.append(",\n");
- sb.append(" \"message\": \"").append(d.getMessage().get()).append("\"");
- }
- // only include data if was enabled
- if (("true".equals(includeData)) && d.getDetails() != null && !d.getDetails().isEmpty()) {
- sb.append(",\n");
- // lets use sorted keys
- Iterator<String> it = new TreeSet<>(d.getDetails().keySet()).iterator();
- sb.append(" \"data\": {\n");
- while (it.hasNext()) {
- String k = it.next();
- Object v = d.getDetails().get(k);
- if (v == null) {
- v = ""; // in case of null value
- }
- boolean last = !it.hasNext();
- sb.append(" \"").append(k).append("\": \"").append(v).append("\"");
- if (!last) {
- sb.append(",");
- }
- sb.append("\n");
- }
- sb.append(" }");
- }
- sb.append("\n");
- }
-
- private static String allCausedByErrorMessages(Throwable e) {
- StringBuilder sb = new StringBuilder();
- sb.append(e.getMessage());
-
- while (e.getCause() != null) {
- e = e.getCause();
- if (e.getMessage() != null) {
- sb.append("; Caused by: ");
- sb.append(ObjectHelper.classCanonicalName(e));
- sb.append(": ");
- sb.append(e.getMessage());
- }
- }
-
- return sb.toString();
- }
-
- private static String errorStackTrace(Throwable e) {
- String trace = ExceptionHelper.stackTraceToString(e);
- // because the stacktrace is printed in json we need to make it safe
- trace = trace.replace('"', '\'');
- trace = trace.replace('\t', ' ');
- trace = trace.replace(System.lineSeparator(), " ");
- return trace;
- }
-
- protected void setupDevConsole() {
- Route dev = router.route("/q/dev");
- dev.method(HttpMethod.GET);
- dev.produces("text/plain");
- dev.produces("application/json");
- Route devSub = router.route("/q/dev/*");
- devSub.method(HttpMethod.GET);
- devSub.produces("text/plain");
- devSub.produces("application/json");
-
- Handler<RoutingContext> handler = new Handler<RoutingContext>() {
- @Override
- public void handle(RoutingContext ctx) {
- String acp = ctx.request().getHeader("Accept");
- int pos1 = acp != null ? acp.indexOf("html") : Integer.MAX_VALUE;
- if (pos1 == -1) {
- pos1 = Integer.MAX_VALUE;
- }
- int pos2 = acp != null ? acp.indexOf("json") : Integer.MAX_VALUE;
- if (pos2 == -1) {
- pos2 = Integer.MAX_VALUE;
- }
- final boolean html = pos1 < pos2;
- final boolean json = pos2 < pos1;
- final DevConsole.MediaType mediaType = json ? DevConsole.MediaType.JSON : DevConsole.MediaType.TEXT;
-
- ctx.response().putHeader("content-type", "text/plain");
-
- if (!camelContext.isDevConsole()) {
- ctx.end("Developer Console is not enabled on CamelContext. Set camel.context.dev-console=true in application.properties");
- }
- DevConsoleRegistry dcr = camelContext.getCamelContextExtension().getContextPlugin(DevConsoleRegistry.class);
- if (dcr == null) {
- ctx.end("Developer Console is not included. Add camel-console to classpath.");
- return;
- } else if (!dcr.isEnabled()) {
- ctx.end("Developer Console is not enabled");
- return;
- }
-
- String path = StringHelper.after(ctx.request().path(), "/q/dev/");
- String s = path;
- if (s != null && s.contains("/")) {
- s = StringHelper.before(s, "/");
- }
- String id = s;
-
- // index/home should list each console
- if (id == null || id.isEmpty() || id.equals("index")) {
- StringBuilder sb = new StringBuilder();
- JsonObject root = new JsonObject();
-
- dcr.stream().forEach(c -> {
- if (json) {
- JsonObject jo = new JsonObject();
- jo.put("id", c.getId());
- jo.put("displayName", c.getDisplayName());
- jo.put("description", c.getDescription());
- root.put(c.getId(), jo);
- } else {
- String link = c.getId();
- String eol = "\n";
- if (html) {
- link = "<a href=\"dev/" + link + "\">" + c.getId() + "</a>";
- eol = "<br/>\n";
- }
- sb.append(link).append(": ").append(c.getDescription()).append(eol);
- // special for top in processor mode
- if ("top".equals(c.getId())) {
- link = link.replace("top", "top/*");
- sb.append(link).append(": ").append("Display the top processors").append(eol);
- }
- }
- });
- if (!sb.isEmpty()) {
- String out = sb.toString();
- if (html) {
- ctx.response().putHeader("content-type", "text/html");
- }
- ctx.end(out);
- } else if (!root.isEmpty()) {
- ctx.response().putHeader("content-type", "application/json");
- String out = root.toJson();
- ctx.end(out);
- } else {
- ctx.end();
- }
- } else {
- Map<String, Object> params = new HashMap<>();
- ctx.queryParams().forEach(params::put);
- params.put(Exchange.HTTP_PATH, path);
- StringBuilder sb = new StringBuilder();
- JsonObject root = new JsonObject();
-
- // sort according to index by given id
- dcr.stream().sorted((o1, o2) -> {
- int p1 = id.indexOf(o1.getId());
- int p2 = id.indexOf(o2.getId());
- return Integer.compare(p1, p2);
- }).forEach(c -> {
- boolean include = "all".equals(id) || c.getId().equalsIgnoreCase(id);
- if (include && c.supportMediaType(mediaType)) {
- Object out = c.call(mediaType, params);
- if (out != null && mediaType == DevConsole.MediaType.TEXT) {
- sb.append(c.getDisplayName()).append(":");
- sb.append("\n\n");
- sb.append(out);
- sb.append("\n\n");
- } else if (out != null && mediaType == DevConsole.MediaType.JSON) {
- root.put(c.getId(), out);
- }
- }
- });
- if (!sb.isEmpty()) {
- String out = sb.toString();
- ctx.end(out);
- } else if (!root.isEmpty()) {
- ctx.response().putHeader("content-type", "application/json");
- String out = root.toJson();
- ctx.end(out);
- } else {
- ctx.end("Developer Console not found: " + id);
- }
- }
- }
- };
- // use blocking handler as the task can take longer time to complete
- dev.handler(new BlockingHandlerDecorator(handler, true));
- devSub.handler(new BlockingHandlerDecorator(handler, true));
-
- platformHttpComponent.addHttpEndpoint("/q/dev", "GET", null,
- "text/plain,application/json", null);
- }
-
- protected void setupUploadConsole(final String dir) {
- final Route upload = router.route("/q/upload/:filename")
- .method(HttpMethod.PUT)
- // need body handler to handle file uploads
- .handler(BodyHandler.create(true));
-
- final Route uploadDelete = router.route("/q/upload/:filename");
- uploadDelete.method(HttpMethod.DELETE);
-
- Handler<RoutingContext> handler = new Handler<RoutingContext>() {
- @Override
- public void handle(RoutingContext ctx) {
- String name = ctx.pathParam("filename");
- if (name == null) {
- ctx.response().setStatusCode(400);
- ctx.end();
- return;
- }
-
- int status = 200;
- boolean delete = HttpMethod.DELETE == ctx.request().method();
- if (delete) {
- if (name.contains("*")) {
- if (name.equals("*")) {
- name = "**";
- }
- AntPathMatcher match = AntPathMatcher.INSTANCE;
- File[] files = new File(dir).listFiles();
- if (files != null) {
- for (File f : files) {
- if (f.getName().startsWith(".") || f.isHidden()) {
- continue;
- }
- if (match.match(name, f.getName())) {
- LOG.info("Deleting file: {}/{}", dir, name);
- FileUtil.deleteFile(f);
- }
- }
- }
- } else {
- File f = new File(dir, name);
- if (f.exists() && f.isFile()) {
- LOG.info("Deleting file: {}/{}", dir, name);
- FileUtil.deleteFile(f);
- }
- }
- } else {
- File f = new File(dir, name);
- boolean exists = f.isFile() && f.exists();
- LOG.info("{} file: {}/{}", exists ? "Updating" : "Creating", dir, name);
-
- File tmp = new File(dir, name + ".tmp");
- FileOutputStream fos = null;
- try {
- fos = new FileOutputStream(tmp, false);
- RequestBody rb = ctx.body();
- IOHelper.writeText(rb.asString(), fos);
-
- FileUtil.renameFileUsingCopy(tmp, f);
- FileUtil.deleteFile(tmp);
- } catch (Exception e) {
- // some kind of error
- LOG.warn("Error saving file: {}/{} due to: {}", dir, name, e.getMessage(), e);
- status = 500;
- } finally {
- IOHelper.close(fos);
- FileUtil.deleteFile(tmp);
- }
- }
-
- ctx.response().setStatusCode(status);
- ctx.end();
- }
- };
- // use blocking handler as the task can take longer time to complete
- upload.handler(new BlockingHandlerDecorator(handler, true));
- uploadDelete.handler(new BlockingHandlerDecorator(handler, true));
-
- platformHttpComponent.addHttpEndpoint("/q/upload", "PUT,DELETE",
- "multipart/form-data", null, null);
- }
-
- protected void setupDownloadConsole() {
- final Route download = router.route("/q/download/*")
- .produces("text/plain")
- .produces("application/octet-stream")
- .method(HttpMethod.GET);
-
- final AntPathMatcher matcher = AntPathMatcher.INSTANCE;
- Handler<RoutingContext> handler = new Handler<RoutingContext>() {
- @Override
- public void handle(RoutingContext ctx) {
- String name = StringHelper.after(ctx.normalizedPath(), "/q/download/");
- boolean cp = "true".equals(ctx.queryParams().get("classpath"));
- if (name == null || name.isBlank() || matcher.isPattern(name)) {
- Set<String> names = new TreeSet<>();
- if (cp) {
- // also look inside classpath
- PackageScanResourceResolver resolver = PluginHelper.getPackageScanResourceResolver(camelContext);
- resolver.addClassLoader(camelContext.getApplicationContextClassLoader());
- try {
- String pattern = "**/*";
- if (name != null && !name.isBlank()) {
- pattern = "**/" + name;
- }
- for (Resource res : resolver.findResources(pattern)) {
- String loc = res.getLocation();
- loc = LoggerHelper.sourceNameOnly(loc);
- names.add(loc);
- }
- } catch (Exception e) {
- // ignore
- }
- }
- // always include routes
- for (org.apache.camel.Route route : camelContext.getRoutes()) {
- String loc = route.getSourceLocation();
- if (loc != null) {
- loc = LoggerHelper.sourceNameOnly(loc);
- if (name == null || name.isBlank() || matcher.match(name, loc)) {
- names.add(loc);
- }
- }
- }
-
- String acp = ctx.request().getHeader("Accept");
- boolean html = acp != null && acp.contains("html");
- StringJoiner sj;
- if (html) {
- String prefix = StringHelper.after(ctx.normalizedPath(), "/q/download/");
- if (prefix == null) {
- prefix = "/q/download/";
- } else {
- prefix = "";
- }
- ctx.response().putHeader("Content-Type", "text/html");
- sj = new StringJoiner("<br/>");
- for (String n : names) {
- sj.add("<a href=" + prefix + n + ">" + n + "</a>");
- }
- } else {
- ctx.response().putHeader("Content-Type", "text/plain");
- sj = new StringJoiner("\n");
- names.forEach(sj::add);
- }
- ctx.response().setStatusCode(200);
- ctx.end(sj.toString());
- } else {
- // load file as resource (try both classpath and file)
- ResourceLoader loader = PluginHelper.getResourceLoader(camelContext);
- Resource res = loader.resolveResource("classpath:" + name);
- if (res == null || !res.exists()) {
- // attempt without path
- res = loader.resolveResource("classpath:" + FileUtil.stripPath(name));
- }
- if (res == null || !res.exists()) {
- for (org.apache.camel.Route route : camelContext.getRoutes()) {
- String loc = route.getSourceLocation();
- if (loc != null) {
- loc = LoggerHelper.sourceNameOnly(loc);
- if (matcher.match(name, loc)) {
- res = route.getSourceResource();
- break;
- }
- }
- }
- }
- if (res != null && res.exists()) {
- ctx.response().putHeader("Content-Type", "application/octet-stream");
- ctx.response().putHeader("Content-Disposition",
- "attachment; filename=\"" + FileUtil.stripPath(name) + "\"");
- ctx.response().setStatusCode(200);
- String data = null;
- try {
- data = IOHelper.loadText(res.getInputStream());
- } catch (IOException e) {
- // ignore
- }
- ctx.end(data);
- } else {
- ctx.response().setStatusCode(204);
- ctx.end();
- }
- }
- }
- };
- // use blocking handler as the task can take longer time to complete
- download.handler(new BlockingHandlerDecorator(handler, true));
-
- platformHttpComponent.addHttpEndpoint("/q/download", "GET",
- null, "text/plain,application/octet-stream", null);
- }
-
- protected void setupSendConsole() {
- final Route send = router.route("/q/send/")
- .produces("application/json")
- .method(HttpMethod.GET).method(HttpMethod.POST)
- // need body handler to have access to the body
- .handler(BodyHandler.create(false));
-
- Handler<RoutingContext> handler = new Handler<RoutingContext>() {
- @Override
- public void handle(RoutingContext ctx) {
- try {
- doSend(ctx);
- } catch (Exception e) {
- LOG.warn("Error sending Camel message due to: " + e.getMessage(), e);
- if (!ctx.response().ended()) {
- ctx.response().setStatusCode(500);
- ctx.end();
- }
- }
- }
- };
- // use blocking handler as the task can take longer time to complete
- send.handler(new BlockingHandlerDecorator(handler, true));
-
- platformHttpComponent.addHttpEndpoint("/q/send", "GET,POST",
- null, "application/json", null);
- }
-
- protected void doSend(RoutingContext ctx) {
- StopWatch watch = new StopWatch();
- long timestamp = System.currentTimeMillis();
-
- String endpoint = ctx.request().getHeader("endpoint");
- String exchangePattern = ctx.request().getHeader("exchangePattern");
- String resultType = ctx.request().getHeader("resultType");
- String poll = ctx.request().getHeader("poll");
- String pollTimeout = ctx.request().getHeader("pollTimeout");
- final Map<String, Object> headers = new LinkedHashMap<>();
- for (var entry : ctx.request().headers()) {
- String k = entry.getKey();
- boolean exclude
- = "endpoint".equals(k) || "exchangePattern".equals(k) || "poll".equals(k)
- || "pollTimeout".equals(k) || "resultType".equals(k) || "Accept".equals(k)
- || filter.applyFilterToExternalHeaders(entry.getKey(), entry.getValue(), null);
- if (!exclude) {
- headers.put(entry.getKey(), entry.getValue());
- }
- }
- final String body = ctx.body().asString();
-
- Exchange out = null;
- Endpoint target = null;
- if (endpoint == null) {
- List<org.apache.camel.Route> routes = camelContext.getRoutes();
- if (!routes.isEmpty()) {
- // grab endpoint from 1st route
- target = routes.get(0).getEndpoint();
- }
- } else {
- // is the endpoint a pattern or route id
- boolean scheme = endpoint.contains(":");
- boolean pattern = endpoint.endsWith("*");
- if (!scheme || pattern) {
- if (!scheme) {
- endpoint = endpoint + "*";
- }
- String quotedEndpoint = Pattern.quote(endpoint);
- for (org.apache.camel.Route route : camelContext.getRoutes()) {
- Endpoint e = route.getEndpoint();
- if (EndpointHelper.matchEndpoint(camelContext, e.getEndpointUri(), quotedEndpoint)) {
- target = e;
- break;
- }
- }
- if (target == null) {
- // okay it may refer to a route id
- for (org.apache.camel.Route route : camelContext.getRoutes()) {
- String id = route.getRouteId();
- Endpoint e = route.getEndpoint();
- if (EndpointHelper.matchEndpoint(camelContext, id, quotedEndpoint)) {
- target = e;
- break;
- }
- }
- }
- } else {
- target = camelContext.getEndpoint(endpoint);
- }
- }
-
- JsonObject jo = new JsonObject();
- if (target != null) {
- Class<?> clazz = null;
- try {
- if (resultType != null) {
- clazz = camelContext.getClassResolver().resolveMandatoryClass(resultType);
- // we want the result as a specific type then make sure to use InOut
- if (exchangePattern == null) {
- exchangePattern = "InOut";
- }
- }
- if (exchangePattern == null) {
- exchangePattern = "InOnly"; // use in-only by default
- }
- final ExchangePattern mep = ExchangePattern.valueOf(exchangePattern);
- long timeout = pollTimeout != null ? Long.parseLong(pollTimeout) : DEFAULT_POLL_TIMEOUT;
- if ("true".equals(poll)) {
- exchangePattern = "InOut"; // we want to receive the data so enable out mode
- out = consumer.receive(target, timeout);
- } else {
- out = producer.send(target, exchange -> {
- exchange.setPattern(mep);
- exchange.getMessage().setBody(body);
- if (!headers.isEmpty()) {
- exchange.getMessage().setHeaders(headers);
- }
- });
- }
- if (clazz != null && out != null) {
- Object b = out.getMessage().getBody(clazz);
- out.getMessage().setBody(b);
- }
- } catch (Exception e) {
- jo.put("endpoint", target.getEndpointUri());
- jo.put("exchangePattern", exchangePattern);
- jo.put("timestamp", timestamp);
- jo.put("elapsed", watch.taken());
- jo.put("status", "failed");
- jo.put("exception",
- MessageHelper.dumpExceptionAsJSonObject(e).getMap("exception"));
- }
- if (out != null && out.getException() != null) {
- jo.put("endpoint", target.getEndpointUri());
- jo.put("exchangeId", out.getExchangeId());
- jo.put("exchangePattern", exchangePattern);
- jo.put("timestamp", timestamp);
- jo.put("elapsed", watch.taken());
- jo.put("status", "failed");
- // avoid double wrap
- jo.put("exception",
- MessageHelper.dumpExceptionAsJSonObject(out.getException()).getMap("exception"));
- } else if (out != null && "InOut".equals(exchangePattern)) {
- jo.put("endpoint", target.getEndpointUri());
- jo.put("exchangeId", out.getExchangeId());
- jo.put("exchangePattern", exchangePattern);
- jo.put("timestamp", timestamp);
- jo.put("elapsed", watch.taken());
- jo.put("status", "success");
- // dump response and remove unwanted data
- JsonObject msg = MessageHelper.dumpAsJSonObject(out.getMessage(), false, false, true, true, true, true,
- BODY_MAX_CHARS).getMap("message");
- msg.remove("exchangeId");
- msg.remove("exchangePattern");
- msg.remove("exchangeType");
- msg.remove("messageType");
- jo.put("message", msg);
- } else if (out != null) {
- jo.put("endpoint", target.getEndpointUri());
- jo.put("exchangeId", out.getExchangeId());
- jo.put("exchangePattern", exchangePattern);
- jo.put("timestamp", timestamp);
- jo.put("elapsed", watch.taken());
- jo.put("status", "success");
- } else {
- // timeout as there is no data
- jo.put("endpoint", target.getEndpointUri());
- jo.put("timestamp", timestamp);
- jo.put("elapsed", watch.taken());
- jo.put("status", "timeout");
- }
- } else {
- // there is no valid endpoint
- ctx.response().setStatusCode(400);
- jo.put("endpoint", endpoint);
- jo.put("exchangeId", "");
- jo.put("exchangePattern", exchangePattern);
- jo.put("timestamp", timestamp);
- jo.put("elapsed", watch.taken());
- jo.put("status", "failed");
- // avoid double wrap
- jo.put("exception",
- MessageHelper.dumpExceptionAsJSonObject(new NoSuchEndpointException(endpoint))
- .getMap("exception"));
- }
- ctx.end(jo.toJson());
- }
-
protected void setupStartupSummary() throws Exception {
MainHttpServerUtil.setupStartupSummary(
camelContext,
diff --git a/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/ManagementHttpServer.java b/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/ManagementHttpServer.java
index 6adabac1153..9b873b7f6d1 100644
--- a/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/ManagementHttpServer.java
+++ b/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/ManagementHttpServer.java
@@ -326,9 +326,15 @@ public class ManagementHttpServer extends ServiceSupport implements CamelContext
consumer = camelContext.createConsumerTemplate();
}
- server = new VertxPlatformHttpServer(configuration);
- // adding server to camel-context which will manage shutdown the server, so we should not do this here
- camelContext.addService(server);
+ VertxPlatformHttpServer mainServer = camelContext.hasService(VertxPlatformHttpServer.class);
+ if (mainServer != null && mainServer.getPort() == configuration.getPort()) {
+ // reuse main server as we use same port
+ server = mainServer;
+ } else {
+ server = new VertxPlatformHttpServer(configuration);
+ // adding server to camel-context which will manage shutdown the server, so we should not do this here
+ camelContext.addService(server);
+ }
pluginRegistry = getCamelContext().getCamelContextExtension().getContextPlugin(PlatformHttpPluginRegistry.class);
if (pluginRegistry == null && pluginsEnabled()) {