davsclaus opened a new pull request, #27916: URL: https://github.com/apache/camel/pull/27916
Step 5 of [CAMEL-25388](https://issues.apache.org/jira/browse/CAMEL-25388): the commands that act on a running integration send their actions with `ActionClient` and find the integration with `ProcessFinder` (CAMEL-25391, #27914), so they report what happened in their exit code. ### Actions without a result `camel cmd start-route`, `stop-route`, `suspend-route`, `resume-route`, `start-group`, `stop-group`, `enable-processor`, `disable-processor`, `gc`, `reload`, `reset-stats`, `logger --logging-level` and `camel trace --action=start/stop` used to write the action file and exit `0`. Now they wait until the integration confirms the action (CAMEL-25390, #27912): - `1` when the action fails, with the error of the integration; - `3` when the route or processor does not exist (`reason: not-found`); - `124` when there is no answer within `--timeout` (10s by default, millis or a duration such as `30s`). The request is withdrawn, so the integration does not run it later. An integration on an older Camel takes the action without confirming it (exit `0`, as agreed in decision f). ### Actions with a result The data commands (`cmd thread-dump`, `heap-histogram`, `heap-dump`, `browse`, `span`, `stub`, `sql`, `load`, `memory-leak`, `route-dump`, `route-structure`, `route-diagram`, `route-topology`, `get bean`, `source`, `route-controller`, `startup-recorder`, `top source`, `get error --diagram`, `get history --diagram`, `get kafka --committed`) exit `124` when the integration does not answer and `1` for an error. Before, they printed "not received within 10 seconds" and exited `1`, or printed nothing and exited `0`. When the integration has no data to show, or the span exporter is not enabled, they exit `1` instead of `0`. ### Finding the integration - A name or pid that matches no running integration exits `3` (before: nothing happened, exit `0`). Without a name and with nothing running, the command exits `0` and prints `No running Camel integrations` on stderr. - `camel eval expression` with such a name exits `3` instead of starting a new Camel: only without a name, or with `--isolated`, does a new Camel evaluate. ### Other fixes - `cmd send` (also the local mode without a name, which always exited `0`), `cmd receive`, `cmd load`, `transform message` and `eval expression` report the outcome in the exit code. A malformed header, `load` without `--source`, and an unknown `--action` (`cmd receive`, `camel trace`) exit `2`. - `--timeout` on every command that waits for an integration (`ActionTimeoutMixin`; `heap-dump` keeps 60s, `send`/`receive`/`transform message` keep their own). - `--json` on the data commands (moved here from CAMEL-25392), and `get history --json` prints one array instead of one document per line. - The `--filter` of `route-dump`, `route-structure` and `get source` takes several names separated by comma, as its description says. A filter that matches no route exits `3`. - `route-structure` reads a source file into a work file of its own (it was shared between commands), and no longer waits 10 seconds for a file that is already written. - Footer examples: `--id` for routes and processors (`camel cmd stop-route myRoute` passed the route id as the integration name), and the right group (`get bean`, `get source`, `eval expression`, `transform message`). - `stub --watch --find` no longer re-quotes its patterns on every refresh, and `--grep` of `log`, `trace` and `receive` no longer NPEs for an integration that starts after the command. - The MCP `camel_render_route_diagram` tool answers a source without routes, or a filter without a match, as a failed diagram with the reason, as before. ### Docs - 4.24 upgrade guide: "camel cmd actions report failures and timeouts". - Generated command docs for the new `--timeout` and `--json` options. ### Tests - `ActionCommandsTest` runs the commands through the CLI against a fake integration (this JVM, answering like the connector of 4.24): confirmed, failed, not-found and unanswered actions with their exit codes, a name that matches nothing, nothing running, an unknown trace action, `thread-dump --json`, a JSON error of a data command, the route-dump filter (several names, no match) and the filter rules. - `ActionCommandTestSupport` answers the request files the way the connector does, so the 27 existing action test classes test the new protocol; the no-match tests now expect exit `3`. - `CamelStartupRecorderActionTest`: not found, and `--json`. - `mvn test` of camel-jbang-core passes. _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]
