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

jamesnetherton pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git


The following commit(s) were added to refs/heads/main by this push:
     new 73d0d33f9c Fixes #9313. Honor camel.main.jmxManagementNamePattern in 
the management extension
73d0d33f9c is described below

commit 73d0d33f9c0afdad71374a1ea67373df0d833b42
Author: James Netherton <[email protected]>
AuthorDate: Mon Oct 12 18:32:40 2026 +0100

    Fixes #9313. Honor camel.main.jmxManagementNamePattern in the management 
extension
    
    Remove the explicit CamelContext.setManagementName call from the management
    extension CamelContextCustomizer. Pre-setting the management name caused
    JmxManagementLifecycleStrategy to bypass the ManagementNameStrategy, so
    camel.main.jmxManagementNamePattern was never applied.
    
    Camel assigns the management name itself on CamelContext startup, so with 
the
    default pattern the resolved name is unchanged.
    
    Co-authored-by: Claude Opus 5.5 <[email protected]>
---
 docs/modules/ROOT/pages/migration-guide/4.0.0.adoc | 17 ++++++
 .../management/CamelManagementRecorder.java        |  1 -
 .../management/it/ManagementNamePatternIT.java     | 24 +++++++++
 .../management/it/ManagementNamePatternTest.java   | 60 ++++++++++++++++++++++
 .../it/ManagementNamePatternTestProfile.java       | 30 +++++++++++
 5 files changed, 131 insertions(+), 1 deletion(-)

diff --git a/docs/modules/ROOT/pages/migration-guide/4.0.0.adoc 
b/docs/modules/ROOT/pages/migration-guide/4.0.0.adoc
index a07e1988e7..06bbfa9e47 100644
--- a/docs/modules/ROOT/pages/migration-guide/4.0.0.adoc
+++ b/docs/modules/ROOT/pages/migration-guide/4.0.0.adoc
@@ -62,3 +62,20 @@ Replace any dependency on 
`org.apache.camel.quarkus:camel-quarkus-junit5` with `
 ----
 
 Any remaining imports of `org.apache.camel.test.junit5` in your tests must be 
updated to `org.apache.camel.test.junit6`. Refer to the 
xref:migration-guide/3.31.0.adoc[Camel Quarkus 3.31.0 migration guide] for 
details.
+
+== Management extension honors `camel.main.jmxManagementNamePattern`
+
+In previous releases, the `camel-quarkus-management` extension ignored the 
`camel.main.jmxManagementNamePattern` option, and the CamelContext management 
name was always the CamelContext name.
+
+The option is now honored. If your application sets 
`camel.main.jmxManagementNamePattern`, the CamelContext management name and the 
`context` key of the Camel MBean `ObjectName` values change to the name 
resolved from the pattern.
+
+For example, with the following configuration, Camel MBeans that were 
previously registered under `org.apache.camel:context=camel-1` are now 
registered under `org.apache.camel:context=custom-camel-1`.
+
+[source,properties]
+----
+camel.main.jmxManagementNamePattern = custom-#name#
+----
+
+Anything that refers to the Camel MBeans by `ObjectName`, such as monitoring 
tools or Jolokia requests, must be updated to use the new name. To retain the 
previous behavior, remove `camel.main.jmxManagementNamePattern` from the 
application configuration.
+
+Applications that do not set `camel.main.jmxManagementNamePattern` are 
unaffected.
diff --git 
a/extensions/management/runtime/src/main/java/org/apache/camel/quarkus/component/management/CamelManagementRecorder.java
 
b/extensions/management/runtime/src/main/java/org/apache/camel/quarkus/component/management/CamelManagementRecorder.java
index b43bea0b7e..89a7919350 100644
--- 
a/extensions/management/runtime/src/main/java/org/apache/camel/quarkus/component/management/CamelManagementRecorder.java
+++ 
b/extensions/management/runtime/src/main/java/org/apache/camel/quarkus/component/management/CamelManagementRecorder.java
@@ -34,7 +34,6 @@ public class CamelManagementRecorder {
         @Override
         public void configure(CamelContext context) {
             context.setManagementNameStrategy(new 
DefaultManagementNameStrategy(context));
-            context.setManagementName(context.getName());
         }
     }
 }
diff --git 
a/integration-tests/management/src/test/java/org/apache/camel/quarkus/component/management/it/ManagementNamePatternIT.java
 
b/integration-tests/management/src/test/java/org/apache/camel/quarkus/component/management/it/ManagementNamePatternIT.java
new file mode 100644
index 0000000000..c6004ff6e7
--- /dev/null
+++ 
b/integration-tests/management/src/test/java/org/apache/camel/quarkus/component/management/it/ManagementNamePatternIT.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.management.it;
+
+import io.quarkus.test.junit.QuarkusIntegrationTest;
+
+@QuarkusIntegrationTest
+class ManagementNamePatternIT extends ManagementNamePatternTest {
+
+}
diff --git 
a/integration-tests/management/src/test/java/org/apache/camel/quarkus/component/management/it/ManagementNamePatternTest.java
 
b/integration-tests/management/src/test/java/org/apache/camel/quarkus/component/management/it/ManagementNamePatternTest.java
new file mode 100644
index 0000000000..ae39035c39
--- /dev/null
+++ 
b/integration-tests/management/src/test/java/org/apache/camel/quarkus/component/management/it/ManagementNamePatternTest.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.management.it;
+
+import io.quarkus.test.junit.QuarkusTest;
+import io.quarkus.test.junit.TestProfile;
+import io.restassured.RestAssured;
+import org.junit.jupiter.api.Test;
+
+import static 
org.apache.camel.quarkus.component.management.it.ManagementNamePatternTestProfile.MANAGEMENT_NAME_PREFIX;
+import static org.hamcrest.Matchers.is;
+
+@QuarkusTest
+@TestProfile(ManagementNamePatternTestProfile.class)
+class ManagementNamePatternTest {
+
+    @Test
+    public void testManagementNamePattern() {
+        String contextName = RestAssured.get("/management/context/name")
+                .then()
+                .statusCode(200)
+                .extract()
+                .body()
+                .asString();
+
+        String managementName = MANAGEMENT_NAME_PREFIX + contextName;
+
+        // The CamelContext management name should be resolved from the 
configured pattern
+        RestAssured.given()
+                .queryParam("name", "org.apache.camel:type=context,*")
+                .queryParam("attribute", "ManagementName")
+                .get("/management/attribute")
+                .then()
+                .statusCode(200)
+                .body(is(managementName));
+
+        // Managed objects should be registered under the management name, and 
still refer to the original CamelContext name
+        RestAssured.given()
+                .queryParam("name", "org.apache.camel:context=" + 
managementName + ",type=routes,*")
+                .queryParam("attribute", "CamelId")
+                .get("/management/attribute")
+                .then()
+                .statusCode(200)
+                .body(is(contextName));
+    }
+}
diff --git 
a/integration-tests/management/src/test/java/org/apache/camel/quarkus/component/management/it/ManagementNamePatternTestProfile.java
 
b/integration-tests/management/src/test/java/org/apache/camel/quarkus/component/management/it/ManagementNamePatternTestProfile.java
new file mode 100644
index 0000000000..07b5aa110d
--- /dev/null
+++ 
b/integration-tests/management/src/test/java/org/apache/camel/quarkus/component/management/it/ManagementNamePatternTestProfile.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.management.it;
+
+import java.util.Map;
+
+import io.quarkus.test.junit.QuarkusTestProfile;
+
+public class ManagementNamePatternTestProfile implements QuarkusTestProfile {
+    static final String MANAGEMENT_NAME_PREFIX = "custom-";
+
+    @Override
+    public Map<String, String> getConfigOverrides() {
+        return Map.of("camel.main.jmxManagementNamePattern", 
MANAGEMENT_NAME_PREFIX + "#name#");
+    }
+}

Reply via email to