[
https://issues.apache.org/jira/browse/CAMEL-26597?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18138220#comment-18138220
]
Claus Ibsen commented on CAMEL-26597:
-------------------------------------
Thanks for the detailed report and the analysis, it is spot on for 4.22.2 and
4.23.0.
This is a duplicate of CAMEL-25554, which is already fixed on main for
*4.24.0*: a route reload now also runs the templated-route pass
({{RoutesBuilder.updateTemplatedRoutesToCamelContext}}), so routes from a
{{templatedRoute}} are created again. Follow-ups CAMEL-25598 and CAMEL-25616
fixed related cases (reloading the file that defines the templated route, and a
route template defined in Java).
The fix is not going to be backported to 4.22.x or 4.18.x: it spans several
tickets and changes the reload logic in camel-core, which is too much for an
LTS branch. It is fixed from 4.24 onwards. You are welcome to try a
4.24.0-SNAPSHOT build in the meantime.
Resolving as Duplicate of CAMEL-25554.
_Claude Code on behalf of davsclaus_
> Route reload drops all routes created from templatedRoute, while the reload
> reports success
> -------------------------------------------------------------------------------------------
>
> Key: CAMEL-26597
> URL: https://issues.apache.org/jira/browse/CAMEL-26597
> Project: Camel
> Issue Type: Bug
> Components: camel-core
> Affects Versions: 4.22.2, 4.23.0
> Reporter: Marat Gubaidullin
> Priority: Major
>
> Routes reloaded with {{camel run --dev}}, the {{reload}} dev console
> ({{/q/dev/reload?reload=true}}), {{camel cmd reload}} or JMX
> ({{RouteOnDemandReloadStrategy}}) lose every route created from a
> {{templatedRoute}} definition. The route templates are registered again, but
> their routes are never recreated. The reload reports success and logs no
> error. Plain routes and Kamelets reload fine.
> h3. Reproducer
> {code:title=t.camel.yaml|language=yaml}
> - routeTemplate:
> id: tick
> route:
> from:
> uri: timer
> parameters:
> timerName: "{{name}}"
> period: 1000
> steps:
> - log:
> message: "tpl {{name}}"
> parameters:
> - name: name
> - templatedRoute:
> routeTemplateRef: tick
> routeId: tick-a
> parameters:
> - name: name
> value: a
> - route:
> id: plain
> from:
> uri: timer:plain
> steps:
> - log:
> message: plain
> {code}
> # {{camel run t.camel.yaml --dev}} (or {{camel run --source-dir=. --console}}
> with camel-console)
> # {{camel get route}} lists {{plain}} and {{tick-a}}
> # Touch the file, or call {{GET /q/dev/reload?reload=true&wait=true}}. The
> log shows {{Routes reloaded summary (total:1 started:1)}}; the console
> answers {{Status: Reload success}}
> # {{camel get route}} lists only {{plain}}. {{tick-a}} stays missing after
> every further reload.
> h3. Expected
> {{tick-a}} is recreated on reload, as at startup.
> h3. Cause
> At startup, camel-main adds templated routes in a separate pass after all
> routes: {{RoutesConfigurer}} (line 368) calls
> {{camelContext.addTemplatedRoutes(builder)}}, which runs
> {{RouteBuilder.addTemplatedRoutesToCamelContext}} →
> {{populateTemplatedRoutes}}.
> The reload path has no such pass:
> * {{RouteWatcherReloadStrategy.onRouteReload}} removes all routes and calls
> {{removeRouteTemplates("*")}}, then {{DefaultRoutesLoader.updateRoutes}}.
> * {{updateRoutes}} calls only {{builder.updateRoutesToCamelContext(...)}} for
> each builder (4.22.2 line 304, 4.23.0 line 321).
> * {{RouteBuilder.updateRoutesToCamelContext}} populates beans, rests,
> transformers, validators, route templates and routes, but not templated
> routes.
> h3. Suggested fix
> In {{DefaultRoutesLoader.updateRoutes}}, once all builders are updated, add
> their templated routes the way startup does:
> {{getCamelContext().addTemplatedRoutes(builder)}} for each builder. Include
> the created route ids in the returned set, so the reload summary and the
> duplicate-id check cover them.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)