davsclaus opened a new pull request, #29853:
URL: https://github.com/apache/camel/pull/29853
## What
A follow-up of CAMEL-26911 (found while doing #29846, a send runs on a
thread of its own).
The Camel CLI waits for the answer of an integration to an action (`camel
cmd send --reply`, `camel cmd receive`, a route dump, the tools of `camel ask`
and the TUI, ...) until its timeout, also when the integration has stopped in
the meantime. For example a `camel cmd send --reply` to a slow route of an
integration that is killed waits the whole `--timeout`, and then says that the
integration did not answer in time (exit code 124).
`ActionClient` now watches the process of the integration while it waits,
and ends as soon as it is gone:
```
$ camel cmd send app --endpoint=direct:slow --body=hi --reply
ERROR: The integration with pid 99497 stopped before it answered the action
send
$ echo $?
3
```
- The exit code is `3`, as for an integration that is not running (the LSB
convention the exit codes follow), and the exit-codes page says so.
- The process is checked before the answer is read, so an answer written
just before the integration stopped is still read.
- Only a process that is alive when the action is sent is watched. An
integration the CLI cannot see as a process (such as one in a container that
shares the Camel directory), and the fake pids of the tests, are waited for
until the timeout, as before. `ProcessHandle.isAlive()` compares the start
time, so a pid that is reused by another process is not taken for the
integration.
- `ActionClient.executeText` (the text API of the AI tools, `RuntimeHelper`
and the observed bodies of the validator) throws
`ActionClient.StoppedException`, so `camel ask`, the TUI and
`RuntimeHelper.executeAction` say that the integration stopped, instead of
reporting a timeout.
- `camel cmd send` and `camel transform message` put "Send timeout:" /
"Transform timeout:" in front of the error only when it is a timeout.
## Tests
- `ActionClientTest`: three new tests with a real process (`sleep 30`,
disabled on Windows) as the integration: it stops while it has the action
(`execute` and `executeText`), and it answers and then stops. With the alive
check turned off, the first two wait the full 30 seconds and fail.
- `ActionClientTest`, `RuntimeHelperTest`, `CamelSendAction*Test`,
`TransformMessageActionTest`, `CamelReceiveActionTest` and the transform tests
pass.
- End to end, with the launcher: a `camel cmd send --reply --timeout=40000`
to a route that waits 60 seconds, and the integration killed after 3 seconds:
| | `send` takes | exit code | message |
|---|---|---|---|
| main | 50.4 s | 124 | `Send timeout: No answer from the integration with
pid ... to the action send within 50000 millis` |
| this PR | 3.1 s | 3 | `The integration with pid ... stopped before it
answered the action send` |
## Docs
- Exit codes page: code `3` also covers an integration that stops before it
answers.
- 4.24 upgrade guide: a bullet in "camel cmd actions report failures and
timeouts".
_Claude Code on behalf of Claus Ibsen (davsclaus)_
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_012nJsFsjqqFiwroeHRWaKbS
--
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]