[ 
https://issues.apache.org/jira/browse/CAMEL-26754?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Work on CAMEL-26754 started by shashank.
----------------------------------------
> camel-cluster - ClusteredRoutePolicy: a route added after the CamelContext 
> started, with an initial delay, never starts
> -----------------------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-26754
>                 URL: https://issues.apache.org/jira/browse/CAMEL-26754
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 4.23.0
>            Reporter: shashank
>            Assignee: shashank
>            Priority: Major
>
> Since CAMEL-25089 the {{ClusteredRoutePolicy}} defers the start of its routes 
> while its initial delay has not elapsed, and only the initial-delay timer 
> sets the delay as elapsed. The timer is armed when the policy learns that the 
> CamelContext has started: from the {{CamelContextStartedEvent}}, or from 
> {{onCamelContextFullyStarted}}. A policy attached to a CamelContext that is 
> already started gets neither: {{CamelContext.addStartupListener}} only calls 
> {{onCamelContextStarted(context, true)}}, which the policy ignores, and the 
> started event was sent before.
> So for a route added after start (a route added with {{addRoutes}}, a route 
> template or kamelet, a reloaded route) with an initial delay:
> * if the node is not the leader when the route is added, the route is set to 
> {{autoStartup=false}};
> * when the node becomes the leader, the policy defers the start "until the 
> initial delay has elapsed", which never happens;
> * the route never starts on this node. On a cluster where every node added 
> the route at runtime, it runs nowhere, also after a failover.
> A node that is the leader when the route is added starts it through the route 
> controller, but once it loses the leadership and takes it again the route is 
> not started again either.
> The {{ClusteredRouteController}} creates such a policy for each route when 
> {{initialDelay}} is set (documented as "the amount of time the route 
> controller should wait before to start the routes after the camel context is 
> started"). It sets the initial delay after the CamelContext, so arming the 
> timer when the CamelContext is set would not work.
> Before CAMEL-25089 (4.23.0) a route added at runtime was started when the 
> node became the leader (the initial delay did not apply to it). 4.22.x is not 
> affected.
> Expected: a route added after start is started when the node is (or becomes) 
> the leader, once the initial delay of its policy has elapsed. For a policy 
> attached after start, the delay can only count from when its first route is 
> added.
> Suggested fix: arm the initial delay in {{onInit}} when the CamelContext is 
> already started (it still applies once).
> Found with Specula (TLA+ model checked against traces of the real code) and 
> confirmed with a test on the real classes.
> _Filed with Claude Code on behalf of allthingssecurity._



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to