Croway opened a new pull request, #27280: URL: https://github.com/apache/camel/pull/27280
_Claude Code on behalf of Croway_ [CAMEL-25267](https://issues.apache.org/jira/browse/CAMEL-25267) ## Problem To find the processors of its route, `ManagedRoute` queried **all** processor MBeans of the CamelContext, created a JMX proxy for each one and read its route id. This happened in `processorIds()`, `dumpRouteStatsAsXml/JSon(includeProcessors=true)`, `dumpStepStatsAsXml`, `dumpRouteSourceLocationsAsXml` and `reset(true)`; the last one used a `QueryExp`, which still reads the attribute of every MBean. The consoles (`route`, `processor`, `top`, `route-group`, `route-topology`) and camel-cli-connector call these for every route, so the cost is routes × processors. The callers then call `ManagedCamelContext.getManagedProcessor(id)` for each id, and that walked every route twice (`CamelContext.getProcessor(id)` and `Model.getProcessorDefinition(id)`). That was a second quadratic cost. ## Fix - `DefaultManagementAgent` indexes the processor and step MBeans it registers, by route id and by processor id. Entries are removed when the MBeans are unregistered. - `ManagedRoute` gets the MBean names of its route from that index for all the methods above. With a custom `ManagementAgent`, it falls back to the previous JMX scan. - `getManagedProcessor(id)` / `getManagedStep(id)` take the processor and its definition from the indexed managed object. The ObjectName is still built by the configured `ManagementObjectNameStrategy`, as before. For an id that is not indexed, they fall back to the previous lookup. No public API, MBean name or result changes. ## Numbers 300 routes × 12 processors, JMX enabled (timing harness attached to the JIRA): | | before | after | |---|---|---| | `processorIds()` for all routes | ~12 s | ~45 ms | | + `getManagedProcessor(id)` for each id | ~13 s | ~65 ms | | `route` console with `processors=true` | ~27 s | ~0.7 s | ## Tests `ManagedRouteProcessorsOfOtherRoutesTest` wraps the MBeanServer and records which processor MBeans are read: - `processorIds()` reads only the MBeans of its own route. - `reset(true)` resets only its own route. - After a route is removed, its processors are no longer found. The first two fail without the fix. The full `camel-management` (531 tests) and `camel-console` (233 tests) suites pass. 🤖 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]
