Claus Ibsen created CAMEL-25598:
-----------------------------------
Summary: camel-core - Routes created from route templates should
record their source files for reload and tooling
Key: CAMEL-25598
URL: https://issues.apache.org/jira/browse/CAMEL-25598
Project: Camel
Issue Type: Improvement
Components: camel-core
Reporter: Claus Ibsen
Fix For: 4.24.0
A route created from a {{templatedRoute}} (or a route template / Kamelet) does
not record which files it comes from, so dev mode reload and tooling cannot
find them.
h3. Problem
* {{Route.getSourceResource()}} is null for a route created from a route
template or Kamelet, although {{Route.getSourceLocation()}} points at the
template's file and line ({{RouteTemplateDefinition.asRouteDefinition}} copies
the input, with its location, but not the resource). The debugger and message
history dev consoles show no source code for these routes, and the management
HTTP server cannot serve their source file.
* The file that declares a {{templatedRoute}} is not recorded anywhere once the
route is created.
* {{RouteWatcherReloadStrategy}} (file-watch reload with
{{removeAllRoutes=true}}, the default) works out which files to load again from
the source resource of the running routes. When one file changes, a file
holding only {{templatedRoute}} entries, or only the {{routeTemplate}}, is not
loaded again: its routes are gone after the reload, or the reload fails with
"Cannot find RouteTemplate" and the previous routes are restored. On-demand
reload loads all files and is not affected.
h3. Proposal
* A route created from a route template gets the template's resource as its
source resource, so {{getSourceResource()}} and {{getSourceLocation()}} agree.
* A route created from a {{templatedRoute}} remembers the resource that
declares it, kept apart from the source resource (the line numbers are in the
template file): {{RouteDefinition}} /
{{NamedRoute.getTemplatedRouteResource()}} and
{{Route.getTemplatedRouteResource()}}. The route template id is exposed on
{{Route}} too.
* Expose both for tools, not only the built-in reloader: JMX
({{ManagedRouteMBean}}: route template id, templated route source) and the
route dev console (JSON and text), so the CLI and MCP tools can show and use
them.
* {{RouteWatcherReloadStrategy}} collects the source resource and the templated
route resource of the running routes (Kamelet routes are skipped: they come
from their Kamelet, and are created again with their parent route).
Follows CAMEL-25554, which makes route reload create the templated routes again.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)