davsclaus opened a new pull request, #27914: URL: https://github.com/apache/camel/pull/27914
Step 3 of [CAMEL-25388](https://issues.apache.org/jira/browse/CAMEL-25388): one way to find running integrations and one way to talk to them, so the command PRs that follow (CAMEL-25393 `camel cmd`, CAMEL-25394 `get`/`top`/`ps`, CAMEL-25395 `stop`/`restart`) only have to call them. ### `ProcessFinder` (replaces the `findPids` copies) - `find(nameOrPid)`, `findAll()`, `requireOne(nameOrPid)` and `requireAny(nameOrPid)`. The last two throw a `CliException` with exit code 3 (CAMEL-25389): `No running Camel integration matches: foo`, or `Name or pid foo matches 2 running Camel integrations: 100 (foo), 200 (foo-eu). Specify a name or pid that matches exactly one.` - Lists the status files in `~/.camel` and keeps the live processes among them, instead of reading a status file for every process on the machine (what the TUI already does). - The same matching as before: a prefix unless the name ends with `!`, wildcards and regular expressions, the integration name or the CamelContext name (not the CLI's default `CamelJBang`). A name never matches this JVM. - Two changes, as agreed in the CAMEL-25388 walkthrough (decision i): - a pid must be a running Camel integration. Before, any pid was used as is, so `camel stop 1234 --kill` killed whatever process had that pid; - an integration whose Camel has stopped (phase 9 or later, such as the launcher of an integration that runs in a child process) is skipped by every command. Only the `cmd` actions skipped it before; `camel ps` listed it. - `ActionBaseCommand`, `ProcessBaseCommand` and `Debug` delegate their `findPids` to it, and so do `RuntimeHelper.discoverProcesses` / `findProcess` (MCP, TUI, `camel ask`). The TUI's own copy moves with CAMEL-25398. ### `ActionClient` - `execute(process, action, options, timeout)` for an action with a result, `send(...)` for one without (route stop, gc ...). Both return an `ActionResult` with `OK`, `ERROR` (with `isNotFound()` for `reason: not-found`), `TIMEOUT` or `UNCONFIRMED`, plus `exitCode()` (0/1/3/124) and `orThrow()`. - It picks the protocol from the Camel version in the status file: a file per request for 4.21 and later (published atomically, both files removed afterwards, removing an unfinished request cancels it), the shared `<pid>-action.json` before that (a stale answer is removed first). - Integrations on 4.24 and later confirm every action (CAMEL-25390, #27912), so `send` waits for the confirmation and no answer is a timeout (124). An older integration takes the action without confirming it: `UNCONFIRMED` (exit 0), as agreed (decision f). - It reads errors the way the connector does: status `failed`/`error`, message from `exception.message`, `error`, then `message`. - `RuntimeHelper.executeAction` delegates to it. The text API still returns the answer as the integration wrote it. ### Shared `--timeout` - `TimeoutConverter`: a number is millis (`20000`, as today), and a duration has units (`30s`, `1m30s`). It is used by the existing `--timeout` of `cmd send`, `cmd receive`, `eval expression`, `transform message` and the `semantic` commands. The commands without one get it when they move to `ActionClient` (CAMEL-25393). ### Docs - 4.24 upgrade guide: "finding integrations by name or PID". - `camel-jbang-managing.adoc`: a pid must be a running integration, and no match exits 3. ### Tests - `ProcessFinderTest`: running, stopped and gone integrations; prefix, `!` and regular expression; the CLI's default context name; a pid must be an integration; this JVM by name and by pid; `requireOne`/`requireAny` messages and exit code 3. - `ActionClientTest`: a fake integration answering like the connector of 4.24, 4.22 and 4.18: result, error, not-found, confirmation, timeout (the request is withdrawn), unconfirmed, the shared action file with a stale answer, version from the status file, error messages, version parsing. - `TimeoutConverterTest`. - `mvn test` of camel-jbang-core: 1962 tests pass. The camel-jbang-mcp and TUI suites (users of `RuntimeHelper`) run in CI. _Claude Code on behalf of davsclaus_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01DDRLJAyf8cDXSg8iX785My -- 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]
