davsclaus opened a new pull request, #27847: URL: https://github.com/apache/camel/pull/27847
Fixes https://issues.apache.org/jira/browse/CAMEL-25670 With `camel run --source-dir`, dev mode watches every file under the source directory (`routesReloadPattern=*`, recursive). Routes that write data files into a folder under it therefore reload themselves. For example, a route copies samples into an `inbox` that another route consumes and moves to `done` or `archive`. The reload restarts the routes with an empty in-memory idempotent repository, so they write again, which reloads them again. In a local-model benchmark the `connect/file-processing` example reloaded every 2.0 s for as long as it ran (63 reloads in 2 minutes), and every reload processed the same files again. ## Changes - **camel-support**: - a part of the reload pattern that starts with `!` excludes what it matches, for example `*,!inbox/**`; - a folder that an exclude matches as a whole (`inbox` for `!inbox/**` or `!inbox`) is not scanned at all, through a new `FileWatcherResourceReloadStrategy.isExcludedDirectory` hook; - when five reloads in a row within 15 s were each for files under the same folder, and none of those files is a route source or a properties, Java or Groovy file, one WARN names the folder and how to leave it out (`camel run --data-dir=inbox`, or `!inbox/**` in `camel.main.routesReloadPattern`). - **camel run**: `--data-dir=inbox,archive`, or `camel.jbang.dataDir` in the `application.properties` of the source directory. It adds those excludes in both the in-process and the separate-JVM dev mode. The option docs, the configuration metadata and its catalog copy are regenerated, and the running guide has a short section on it. - **Built-in examples**: of the 11 that use the file component, three write into their own folder. Each now declares its data folders in `application.properties`: `file-processing` (`samples,inbox,archive`), `error-handling` (`orders,parked`) and `csv-to-json` (`inbox,outbox`). When an example runs with `--example`, dev mode only watches its route files anyway; the property matters when its folder runs with `--source-dir`. ## Tests - `RouteWatcherReloadDataDirTest` (camel-core, 7 tests): - every file is watched without an exclude; - an excluded folder is not scanned, and what is written or moved in it is no change; - `!inbox` works like `!inbox/**`; - a file exclude (`!*.json`) leaves files out but not folders; - the warning comes once after five reloads for one folder within 15 s, and not when the reloads are slow, are for sources, or are for different folders. - `RunTest`: the option parses, and `sourceDirReloadPattern` trims, normalises and skips empty entries. - The existing reload tests in camel-core still pass (31 in total with the new ones). 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01STT6whBgK1AqsSsUKrnE8m -- 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]
