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

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


The following commit(s) were added to refs/heads/main by this push:
     new 90e8705dd70f CAMEL-25073: camel-management - Do not register 
components with mbeansLevel=ContextOnly (#27462)
90e8705dd70f is described below

commit 90e8705dd70f975428ec9af415541d8df31ec8c2
Author: allthingssecurity <[email protected]>
AuthorDate: Wed Oct 7 13:40:28 2026 +0530

    CAMEL-25073: camel-management - Do not register components with 
mbeansLevel=ContextOnly (#27462)
    
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
 .../camel/management/JmxManagementLifecycleStrategy.java      |  4 ++++
 .../camel/management/ManagedMBeansLevelContextOnlyTest.java   | 11 +++++++++++
 .../modules/ROOT/pages/camel-4x-upgrade-guide-4_23.adoc       |  7 +++++++
 3 files changed, 22 insertions(+)

diff --git 
a/core/camel-management/src/main/java/org/apache/camel/management/JmxManagementLifecycleStrategy.java
 
b/core/camel-management/src/main/java/org/apache/camel/management/JmxManagementLifecycleStrategy.java
index be8b67f02ede..e81ece038129 100644
--- 
a/core/camel-management/src/main/java/org/apache/camel/management/JmxManagementLifecycleStrategy.java
+++ 
b/core/camel-management/src/main/java/org/apache/camel/management/JmxManagementLifecycleStrategy.java
@@ -437,6 +437,10 @@ public class JmxManagementLifecycleStrategy extends 
ServiceSupport implements Li
             preServices.add(lf -> lf.onComponentAdd(name, component));
             return;
         }
+        // but not with mbeansLevel=ContextOnly, which only registers the 
CamelContext
+        if 
(!getManagementStrategy().getManagementAgent().getMBeansLevel().isRoutes()) {
+            return;
+        }
         try {
             Object mc = 
getManagementObjectStrategy().getManagedObjectForComponent(camelContext, 
component, name);
             manageObject(mc);
diff --git 
a/core/camel-management/src/test/java/org/apache/camel/management/ManagedMBeansLevelContextOnlyTest.java
 
b/core/camel-management/src/test/java/org/apache/camel/management/ManagedMBeansLevelContextOnlyTest.java
index b2816df03571..68019a105b80 100644
--- 
a/core/camel-management/src/test/java/org/apache/camel/management/ManagedMBeansLevelContextOnlyTest.java
+++ 
b/core/camel-management/src/test/java/org/apache/camel/management/ManagedMBeansLevelContextOnlyTest.java
@@ -21,6 +21,8 @@ import java.util.Set;
 import javax.management.ObjectName;
 
 import org.apache.camel.ManagementMBeansLevel;
+import org.apache.camel.component.seda.SedaComponent;
+import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.condition.DisabledOnOs;
 import org.junit.jupiter.api.condition.OS;
 
@@ -39,4 +41,13 @@ public class ManagedMBeansLevelContextOnlyTest extends 
ManagedMBeansLevelTestSup
         assertEquals(0, routes.size());
         assertEquals(0, processors.size());
     }
+
+    @Test
+    void testNoComponentMBeans() throws Exception {
+        // also a component added after CamelContext has been started
+        context.addComponent("mySeda", new SedaComponent());
+
+        Set<ObjectName> components = getMBeanServer().queryNames(new 
ObjectName("*:type=components,*"), null);
+        assertEquals(0, components.size(), "There should be no component 
MBeans: " + components);
+    }
 }
diff --git 
a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_23.adoc 
b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_23.adoc
index 60e5212a3d24..b7c497ad1d28 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_23.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_23.adoc
@@ -736,6 +736,13 @@ succeeded on its second redelivery reported 1 instead of 
2, and a route whose ex
 completed reported 0), and a processor or route that the exchange went through 
after a redelivery could count that
 redelivery as well.
 
+==== mbeansLevel=ContextOnly
+
+With `mbeansLevel=ContextOnly` the components are no longer registered as 
MBeans (like the endpoints, thread pools
+and most services, which were not registered at this level already). Prior to 
Camel 4.23 an MBean was registered for
+every component. Use `RoutesOnly` (or `Default`) to keep the component MBeans. 
The CamelContext, health check and route
+controller MBeans are still registered.
+
 === camel-groovy
 
 A `GroovyShellFactory` is now looked up in the registry once per 
`CamelContext`, when the first groovy expression is

Reply via email to