Claus Ibsen created CAMEL-28097:
-----------------------------------
Summary: camel-core - routes added with
ModelCamelContext.addRouteDefinition (and JMX updateRouteFromXml) get no route
configurations
Key: CAMEL-28097
URL: https://issues.apache.org/jira/browse/CAMEL-28097
Project: Camel
Issue Type: Bug
Components: camel-core
Reporter: Claus Ibsen
Fix For: 4.25.0
h3. Problem
{{DefaultCamelContext.startRouteDefinitions}} prepares a route that is not
prepared yet with {{RouteDefinitionHelper.prepareRoute(ctx, routeDefinition)}}
({{core/camel-core-engine/src/main/java/org/apache/camel/impl/DefaultCamelContext.java:770-773}}).
That method does not merge the route configurations; only
{{RoutesDefinition.prepareRoute}} does (as used by {{RouteBuilder}} and by
{{DefaultModel.addRouteFromTemplate}}).
So a route added with {{ModelCamelContext.addRouteDefinition(s)}} with a
{{RouteDefinition}} that is not prepared yet starts without its route
configurations, global or named. This includes JMX
{{ManagedRoute.updateRouteFromXml}}
({{core/camel-management/.../ManagedRoute.java:922-957}}): the replacement
route loses the global onException the original route had.
h3. Proposed fix
Prepare such a route with the route configurations of the {{CamelContext}}, as
{{DefaultModel.addRouteFromTemplate}} does ({{new
RoutesDefinition().prepareRoute(def)}}).
This changes behaviour: routes added this way start getting the matching route
configurations. It needs an entry in the 4.25 upgrade guide.
Tests: {{addRouteDefinition}} of a route applies the global and the named
configuration; {{updateRouteFromXml}} keeps the global onException.
Found while analysing CAMEL-25142 (late binding of cross-cutting features),
with probe tests on main (4a354d948e9c).
_Claude Code on behalf of davsclaus_
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)