davsclaus opened a new pull request, #27745: URL: https://github.com/apache/camel/pull/27745
_Claude Code on behalf of davsclaus_ Fixes [CAMEL-25554](https://issues.apache.org/jira/browse/CAMEL-25554). ### Problem A route reload drops the routes created from `templatedRoute` entries: an on-demand reload of a file with a plain route, a `routeTemplate` and two `templatedRoute` entries reports success but only the plain route is back. `RouteBuilder.updateRoutesToCamelContext` updates the routes and route templates, but nothing on the update path creates the templated routes (on startup that is the separate `addTemplatedRoutesToCamelContext` step). With `routesReloadRemoveAllRoutes=false` the templated route survived the reload, but a changed parameter was ignored, because the route was never created again. ### Fix - `RoutesBuilder` gets a default method `updateTemplatedRoutesToCamelContext` (`@since 4.24`) that returns the ids of the routes it creates. - `RouteBuilder` implements it: it creates the templated routes, returns the ids of the routes that are new in the model (a route from the same template replaces the existing one, as allowed since CAMEL-25068), and starts them under a `SupervisingRouteController` like `updateRoutesToCamelContext` does. - `DefaultRoutesLoader.doUpdateRoutes` calls it in a last pass, after all builders updated their routes and templates. This is the same order as loading (CAMEL-18764), so a `templatedRoute` can still use a template from another file. Calling it from `updateRoutesToCamelContext` itself would fail when the file with the templated routes is updated before the file with the template. The ids are part of the reload summary and of the duplicate route id check. ### Tests - `RouteReloadOnDemandTemplatedRouteTest`: on-demand reload of the reporter's file shape (3 routes before and after, changed values in use), and an update where the file with the templated routes comes before the file with the template. - `RouteReloadTemplatedRouteTest` (removeAllRoutes=false) now also checks the templated route uses the changed parameter. All three failed before the fix. Ran: camel-yaml-dsl (477 tests), camel-kamelet (94), targeted camel-core reload/template/loader tests (139), camel-main reload/template tests, `LwJavaParserSecurityTest`, and a full `mvn clean install -DskipTests`. ### Not in this PR - With `removeAllRoutes=false` a reloaded `routeTemplate` is added next to the old one with the same id, and the first one is used, so a change to the template body is not picked up on that path. - A route created from a template has no source resource (`RouteTemplateDefinition.asRouteDefinition` does not copy it), so a file-watch reload with `removeAllRoutes=true` of another file does not collect a file holding only `templatedRoute` entries (or only templates). On-demand reload passes all files, so it is not affected. 🤖 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]
