gnodet opened a new pull request, #27430: URL: https://github.com/apache/camel/pull/27430
## Summary Fixes [CAMEL-25135](https://issues.apache.org/jira/browse/CAMEL-25135): a `routeConfiguration` carrying an `onCompletion` fired correctly in the YAML DSL but silently did nothing in the Java DSL as soon as the opted-in route was not itself the consumer route (the common REST DSL → `direct:` shape). ## Root Cause `RouteConfigurationDefinition.onCompletion()` (Java DSL) unconditionally set `routeScoped=false` on every `OnCompletionDefinition` it created. `OnCompletionProcessor.shouldSkip()` uses this flag to decide whether to execute: ```java if (!routeScoped && currentRouteId != null && !routeId.equals(currentRouteId)) { return true; // skip } ``` When a consumer route (REST DSL) routes to a `direct:` processing route that carries a named `routeConfigurationId`, the exchange's "current route" at completion time is the consumer, not the `direct:` route. The two IDs never match → the processor is silently skipped. The YAML DSL left `routeScoped` at its model default (`true`), which activates the visit-tracking mechanism (`ON_COMPLETION_ROUTE_IDS` property set in `onAfterRoute`) and fires correctly regardless of which route is the actual consumer. `onException` is unaffected because `RouteDefinitionHelper.initOnExceptions()` normalises the flag (sets `routeScoped=false`) for all context-scoped on-exceptions. `initOnCompletions()` has no equivalent normalization. ## Fix In `RouteConfigurationDefinition.onCompletion()`, only set `routeScoped=false` for **wildcard** (no-id) route configurations, where it is needed to de-duplicate the onCompletion across all the routes it applies to. For **named** route configurations (specific id), leave `routeScoped` at its default (`true`) so the route-visit tracking mechanism fires correctly even when the opted-in route is an indirect sub-route. ```java if (getId() == null) { // wildcard config: de-dup via routeId == currentRouteId answer.setRouteScoped(false); } // named config: routeScoped=true (default) → uses visit-tracking ``` ## Testing - All existing `RoutesConfigurationOnCompletionTest` and `RouteConfigurationOnCompletionTest` tests continue to pass (3 + 3 existing tests). - New test `testLocalConfigurationWithIndirectConsumer` added to `RoutesConfigurationOnCompletionTest` to cover the exact bug scenario: consumer route (`direct:consumer`) routes to a processing route (`direct:processor`) that carries `routeConfigurationId("myconfig")`. The `onCompletion` from the named configuration must fire exactly once. _This PR was generated by an AI coding agent (Claude Sonnet 4.6) on behalf of gnodet._ -- 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]
