[
https://issues.apache.org/jira/browse/CAMEL-26597?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Claus Ibsen resolved CAMEL-26597.
---------------------------------
Resolution: Duplicate
> 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)