allthingssecurity opened a new pull request, #29292:
URL: https://github.com/apache/camel/pull/29292

   # Description
   
   [CAMEL-25962](https://issues.apache.org/jira/browse/CAMEL-25962)
   
   Follow-up of Claus's review of #28260 (CAMEL-25839, point 1). The route a 
Kamelet endpoint created while the context runs is removed when the endpoint is 
shut down. The removal waited, retrying every 100 ms without limit, until no 
thread of the route's thread pools ran a task, as the calling route can 
continue on such a thread. For the endpoint of a removed route that consumed 
from a source Kamelet (`from("kamelet:my-source")`) there is no calling route: 
the Kamelet's route keeps routing the messages of its own consumer, and with a 
slow step and steady input its `threads()` pool never went idle, so the route 
was never removed and the remover kept polling.
   
   Change (`KameletComponent`), both of the options from that review:
   - The endpoint records whether a route consumed from it and whether a 
producer sent to it. When it was only the input of a removed route, the 
Kamelet's route is removed without waiting for idle pools; it stops gracefully, 
as any route.
   - Otherwise the removal waits for idle pools at most the timeout of the 
shutdown strategy (45 s by default), then logs a WARN and removes the route 
anyway. Stopping the route then shuts its pool down under a calling route still 
running on it, which is what stopping the route did before the wait was added.
   
   The 4.24 upgrade-guide section of CAMEL-25839 (unreleased) gets two 
sentences. A dynamic `pollEnrich` with `cacheSize=-1` creates a polling 
consumer, so its Kamelet route is removed without the wait too (the exchange 
comes through a queue, so no caller runs on the pool).
   
   Not covered, so this PR does not resolve all of CAMEL-25962: a thread pool 
that a component of the route creates for itself (such as the worker pool of an 
asynchronous Kafka producer), and executor services that are not a 
`ThreadPoolExecutor` (virtual threads). They need a way to attribute those 
pools to the route; I would move them to a follow-up JIRA linked from 
CAMEL-25962 and CAMEL-25839.
   
   Tests (`KameletRouteRemovalBusyPoolTest`, latches and an event notifier):
   - A source Kamelet (timer, `threads(1)`) whose pool is held busy until the 
Kamelet's route stops its consumer: removing the route that consumed from it 
removes the Kamelet's route. On main the pool never goes idle and the route is 
still there after 10 s.
   - `recipientList` with `cacheSize=-1` whose caller continues on the 
Kamelet's pool until that route stops, with a shutdown timeout of 2 s: the 
route is removed after the timeout. On main it waits for the caller.
   - Both fail against main code and pass with the change; 20x together with 
`KameletToDRoutesNotKeptTest`: 240/240. camel-kamelet unit tests (offline): 156 
run, 0 failures, 3 skipped.
   
   # Target
   
   - [x] I checked that the commit is targeting the correct branch (Camel 4 
uses the `main` branch)
   
   # Tracking
   - [x] If this is a large change, bug fix, or code improvement, I checked 
there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for 
the change (usually before you start working on it): 
[CAMEL-25962](https://issues.apache.org/jira/browse/CAMEL-25962).
   
   # Apache Camel coding standards and style
   
   - [x] I checked that each commit in the pull request has a meaningful 
subject line and body.
   - [ ] I have run `mvn clean install -DskipTests` locally from root folder 
and I have committed all auto-generated changes.
     (I built camel-kamelet and the modules it depends on, including the 
formatter and import-sort plugins, and ran its unit tests. No generated file 
changes. I did not run the full root build.)
   
   # AI-assisted contributions
   
   - [x] If this PR includes AI-generated code, commits have proper 
co-authorship attribution (e.g., `Co-authored-by` trailers) and the PR 
description identifies the AI tool used.
     This PR was prepared with Claude Code (Claude Opus 5.5). The commit 
carries a `Co-Authored-By` trailer.
   
   _Claude Code on behalf of allthingssecurity_
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to