[
https://issues.apache.org/jira/browse/CAMEL-25142?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18155164#comment-18155164
]
Claus Ibsen commented on CAMEL-25142:
-------------------------------------
Design document updated with the analysis of December 2026:
https://github.com/apache/camel/pull/31332 (merged as f3537e7ac877). The bugs
found are CAMEL-28096 to CAMEL-28101.
_Claude Code on behalf of Claus Ibsen_
> camel-core - Late binding of onException, interceptors, onCompletion and
> route configurations, so they keep working when routes and configurations
> change at runtime
> --------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: CAMEL-25142
> URL: https://issues.apache.org/jira/browse/CAMEL-25142
> Project: Camel
> Issue Type: Improvement
> Components: camel-core
> Reporter: Claus Ibsen
> Assignee: Claus Ibsen
> Priority: Major
> Fix For: 4.25.0
>
>
> The cross-cutting features (onException, error handler, intercept,
> interceptFrom, interceptSendToEndpoint, onCompletion) and the route
> configurations that hold them are bound to the routes when the routes are
> created. This performs well, but it does not keep working when the routes or
> the configurations change while Camel runs, which the more dynamic and
> low-code use of Camel (dev reload, adding/removing routes, restarting the
> CamelContext, route configurations managed by tooling) needs.
> h3. How it works today
> * *Model time:* when a route is prepared, the builder-level definitions and
> the matching route configurations are merged into the route's outputs
> (RoutesDefinition.prepareRoute, RouteDefinitionHelper.prepareRoute). The
> definition objects are shared by all the routes, and a route is prepared only
> once (isPrepared).
> * *Reify time:* each route builds its own processors from them. onException
> becomes exception policies in an error handler, and the error handler is
> created per Channel (per EIP node), each with its own policy map. intercept
> becomes an InterceptStrategy that wraps each Channel when the Channel is
> built. onCompletion becomes route processors. interceptSendToEndpoint wrapped
> endpoints (see CAMEL-25140).
> * *After that the binding is fixed:*
> ** adding/removing a route configuration at runtime (ModelCamelContext) only
> changes the list; the routes that use it are not updated.
> ** dev reload works because it removes all the routes and loads all the files
> again (removeAllRoutes=true). With removeAllRoutes=false, routes in other
> files keep the old configuration. Route configurations removed from a file
> are never removed.
> ** a CamelContext restart creates the routes again from the prepared
> definitions, but intercept and interceptSendToEndpoint removed their
> definitions from the route outputs, so they are lost (interceptSendToEndpoint
> is fixed in CAMEL-25140).
> ** intercept only wraps the Channels built after it is reified, so the steps
> of an interceptFrom may not be intercepted (from reading the code, not
> verified).
> Related older tickets: CAMEL-18923 (updating a route configuration is not
> supported, as it is global and affects running routes), CAMEL-5629 (adding an
> intercept at runtime), CAMEL-3870 (reusable onExceptions, which led to route
> configurations), CAMEL-13912 (create error handlers when reifying rather than
> at runtime, for performance), CAMEL-25140, CAMEL-25141.
> h3. Analysis (December 2026)
> The current state was checked with probe tests on main. The details, the bugs
> found and the plan are in the design document
> (https://github.com/apache/camel/pull/31332). Bugs found, filed on their own:
> * CAMEL-28096: a lookup by id makes global route configurations non-global,
> so they are never replaced or removed
> * CAMEL-28097: routes added with addRouteDefinition (and JMX
> updateRouteFromXml) get no route configurations
> * CAMEL-28098: the YAML dump after a route configuration update writes the
> old onException as a top-level one
> * CAMEL-28099: AdviceWith merges the route configurations twice
> * CAMEL-28100: intercept is lost when a route is created again; the steps of
> onCompletion should not be intercepted
> * CAMEL-28101: route configurations removed from a file, or in a deleted
> file, are never removed on reload
> h3. Decisions
> # Restarting a route is an acceptable meaning of "the route configuration was
> updated" in Camel 4.x. Late binding without a restart is left for Camel 5.
> # intercept is meant for the main route path. The steps of onCompletion are
> no longer intercepted (CAMEL-28100).
> # Any change of a route configuration that applies to a route bumps the
> revision of that route.
> # Only the routes loader (RoutesLoader.updateRoutes) triggers the refresh of
> the routes.
> h3. Plan (Camel 4.x)
> # The bugs above, each on its own.
> # The error handlers of a route share one map of exception policies instead
> of a copy each.
> # Keep the route as written (a deep copy before the merge), and move the
> merge into one method that Spring/Blueprint XML also uses.
> # At the end of RoutesLoader.updateRoutes, merge the current route
> configurations again into the routes they affect and restart only those
> routes; include the merged configurations in the route checksum.
> Real late binding (routes resolve the cross-cutting features while they run,
> without a restart) touches the error handler, the Channel and public APIs. It
> is a goal for Camel 5, after CAMEL-24980.
> _Claude Code on behalf of davsclaus_
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)