allthingssecurity opened a new pull request, #27462: URL: https://github.com/apache/camel/pull/27462
# Description [CAMEL-25073](https://issues.apache.org/jira/browse/CAMEL-25073) Addresses item 5 of CAMEL-25073, which @davsclaus listed after his deep review of #26959 (CAMEL-25065): components are registered with `mbeansLevel=ContextOnly`. `ContextOnly` is documented as "Only register the CamelContext MBean". Since CAMEL-18085 (which introduced the level) `shouldRegister` checks it, so endpoints, services, thread pools, routes and processors are not registered at this level. `JmxManagementLifecycleStrategy.onComponentAdd` does not go through `shouldRegister` (components are always registered, "as there are only a few of those"), so an MBean was still registered for every component, also for one added after the CamelContext has started. CAMEL-18085 only added the level check to `shouldRegister` and `registerProcessor`, so this looks like an oversight rather than a choice. `onComponentAdd` now returns early when the level does not include routes. `RoutesOnly` and `Default` register the components as before. Removing a component is unchanged (unregistering a name that is not registered is a no-op). Not changed: the `DefaultHealthCheck` and route controller MBeans that `onContextStarting` registers next to the CamelContext MBean are still registered with `ContextOnly` (with this change these two and the CamelContext MBean are the only ones left at this level, also with tracing, message history, a `threads` EIP and a health check registry). They are one per CamelContext and act on the CamelContext, CAMEL-18085 was about how many MBeans are installed, and the ticket does not mention them, so I left them; I can include them if you prefer. As users with `ContextOnly` can notice that the component MBeans are gone, the 4.23 upgrade guide has a `==== mbeansLevel=ContextOnly` note under `=== camel-management`, which also says which MBeans remain. Related: the other items of CAMEL-25073 come as separate PRs, opened together with this one: item 1 (a CamelContext name with characters that are not allowed in an ObjectName, branch `camel-management-context-name-object-name`); item 2 (the shared MBean of a context-scoped onException, branch `camel-management-onexception-shared-mbean`); item 3 (endpoints that only differ in a masked secret, branch `camel-management-masked-endpoint-unregister`); item 4 (thread pools of the same source, branch `camel-management-thread-pool-source-id`). Items 1, 2, 3 and 5 change different methods of `JmxManagementLifecycleStrategy`; all five merge cleanly with each other in any order, and the camel-management tests pass with all five merged. Tests: `ManagedMBeansLevelContextOnlyTest.testNoComponentMBeans` (also adds a component after start) fails without the change in two runs (`There should be no component MBeans: [...name="direct", ...name="seda", ...name="mock", ...name="mySeda"] ==> expected: <0> but was: <4>`). That `RoutesOnly` still registers the components is already covered by the existing `ManagedMBeansLevelRoutesOnlyTest` (it fails if `onComponentAdd` skips that level too). Whole `camel-management` module: 532 tests, 0 failures (1 skipped). # Target - [x] I checked that the commit is targeting the correct branch (Camel 4 uses the `main` branch) # Tracking - [x] If this is a large change, bug fix, or code improvement, I checked there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for the change (usually before you start working on it). # Apache Camel coding standards and style - [x] I checked that each commit in the pull request has a meaningful subject line and body. - [ ] I have run `mvn clean install -DskipTests` locally from root folder and I have committed all auto-generated changes. (I built and tested `core/camel-management`, including the formatter and import-sort plugins. No generated files change. I did not run the full root build.) # AI-assisted contributions - [x] If this PR includes AI-generated code, commits have proper co-authorship attribution (e.g., `Co-authored-by` trailers) and the PR description identifies the AI tool used. This PR was prepared with Claude Code (Claude Opus 5.5). The commit carries a `Co-Authored-By` trailer. _Claude Code on behalf of allthingssecurity_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
