davsclaus opened a new pull request, #26038:
URL: https://github.com/apache/camel/pull/26038

   ## Description
   
   Fixes [CAMEL-24590](https://issues.apache.org/jira/browse/CAMEL-24590).
   
   `ManagedRouteGroupMBean.getFailuresHandled()` / 
`getLastExchangeFailureHandledTimestamp()` (and in fact **all** group-level 
performance statistics) did not aggregate across the group's member routes. 
They silently reported the counters of a single arbitrary member route — 
whichever route in the group was registered first.
   
   ### Root cause
   
   `ManagedRouteGroup` extends `ManagedPerformanceCounter` (it owns a counter; 
it does not sum member routes on read). The group counter is fed through a 
`CompositePerformanceCounter` wired onto every member route in 
`JmxManagementLifecycleStrategy.onRoutesAdd`.
   
   The problem: `getManagedObjectForRouteGroup(...)` creates a **new** 
`ManagedRouteGroup` instance on every call, so each member route's composite 
counter was wired to a *different* instance. Only the first route's instance 
was actually registered as the JMX MBean (subsequent registrations are skipped 
because the ObjectName already exists). Every other member route's events went 
to unregistered instances, so `getManagedRouteGroup(group)` returned a proxy 
reflecting just the first-registered route.
   
   This is why the reproducer showed group `completed=1` (a single member's 
count, not the sum of 3) and `failuresHandled=0` (the failing route was not the 
first-registered one).
   
   ### Fix
   
   Cache a single `ManagedRouteGroup` per group name in 
`JmxManagementLifecycleStrategy` so all member routes share the same counter 
instance. The composite counter then aggregates every member route's events 
into the one registered MBean, producing a true group-wide total — matching the 
documented semantics ("total number of Exchange(s) that has failed within this 
group", see `route-group.adoc`). The cached instance is evicted when the 
group's last route is removed and cleared on stop.
   
   ## Tests
   
   - New `ManagedRouteGroupFailuresHandledTest` mirrors the reporter's 
reproducer (handled failure on a trigger route that hops to sibling routes in 
the same group) and asserts the group reports `failuresHandled=1`, a non-null 
last-handled-failure timestamp, and `exchangesCompleted=3` (true aggregate).
   - Updated `ManagedRouteGroupTest` whose `ExchangesTotal` expectation 
previously encoded the buggy per-route value (`1`) — now asserts the aggregate 
(`3` for group `first`, `2` for group `second`).
   - All 89 tests matching `*RouteGroup* / *ManagedRoute* / *Statistic* / 
ManagedCamelContext*` pass.
   
   ---
   _Generated by Claude Code on behalf of davsclaus_
   


-- 
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]

Reply via email to