You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by "Croway (via GitHub)" <gi...@apache.org> on 2026/10/02 12:03:23 UTC
[PR] CAMEL-25197: camel-cli-connector - do not let a slow status starve the WebSocket heartbeat [camel]
Croway opened a new pull request, #27279:
URL: https://github.com/apache/camel/pull/27279
[CAMEL-25197](https://issues.apache.org/jira/browse/CAMEL-25197) follow-up.
With a large integration the WebSocket transport could not stay connected. The status snapshot of 316 YAML routes (about 4000 processors) took about 30 s to collect (the cause is filed as [CAMEL-25267](https://issues.apache.org/jira/browse/CAMEL-25267)). The transport collected it on the thread that also sends heartbeats, so the connection was declared dead ("no heartbeat") and dropped about every 65 s, and `hello`, which collected a full status for its `runtime` section, took 30 s after each reconnect.
- Snapshots are collected on their own thread (`CliConnectorSnapshots`) and handed to the scheduler, which alone sends, so heartbeats and action results are never held up.
- `hello` uses the new `CliSnapshotProducer.runtime()` (default method, `LocalCliConnector` collects only that section).
- The next snapshot round waits at least as long as the previous one took, so a slow status does not keep a CPU busy.
Tested: the module tests (34) pass. End to end through the Kaoto Kompanion with 316 extra routes per app, on Camel Main, Spring Boot (JDK and Spring clients) and Quarkus (JDK and Vert.x clients): `hello` arrives about 1 s after connecting, and every app stays on its first connection throughout functional checks, a load phase and `stop`. Before the fix the same apps reconnected about every 65 s.
_Claude Code on behalf of Croway_
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-25197: camel-cli-connector - do not let a slow status starve the WebSocket heartbeat [camel]
Posted by "Croway (via GitHub)" <gi...@apache.org>.
Croway merged PR #27279:
URL: https://github.com/apache/camel/pull/27279
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-25197: camel-cli-connector - do not let a slow status starve the WebSocket heartbeat [camel]
Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus commented on code in PR #27279:
URL: https://github.com/apache/camel/pull/27279#discussion_r4165608802
##########
dsl/camel-cli-connector/src/main/java/org/apache/camel/cli/connector/WebSocketCliConnectorTransport.java:
##########
@@ -94,12 +94,15 @@ public class WebSocketCliConnectorTransport extends ServiceSupport implements Cl
private CliWebSocketClient client;
private ThreadPoolExecutor actions;
private ScheduledExecutorService scheduler;
+ // collects snapshots: the status of a large integration can take seconds, which must not hold up the scheduler
+ // (heartbeats, sends); snapshots are handed to the scheduler to be sent
+ private ScheduledExecutorService collector;
// fields below are only used from the scheduler thread, except the volatile ones
Review Comment:
With this PR, `ticks`, `snapshotFuture` and `debugFuture` (below), and `lastTraceUid` / `lastReceiveUid` / `lastSent` on `Connection`, are only used on the collector thread, not the scheduler. Could you update this comment, the one on the `Connection` fields, and the class javadoc ("connecting, parsing the incoming frames, snapshots, heartbeats ... run on a second thread")? The class relies on these comments to explain who owns what.
##########
dsl/camel-cli-connector/src/main/java/org/apache/camel/cli/connector/WebSocketCliConnectorTransport.java:
##########
@@ -491,7 +521,8 @@ private void sendSnapshot(Connection c, String kind, JsonObject data) {
JsonObject frame = envelope("snapshot");
frame.put("kind", kind);
frame.put("data", data);
- send(c, frame);
+ // only the scheduler sends, one frame at a time
+ execute(() -> send(c, frame));
Review Comment:
Before this change, collecting and sending on one thread gave natural backpressure. Now the next round waits for the collection time but not the send time, and the collector keeps adding frames to the scheduler's unbounded queue, including trace/receive batches of up to 128 KB each. On a slow link where sends succeed but each takes seconds, the queue can keep growing, and pings wait behind those sends. A failed send closes the connection and the rest of the queue is then dropped, so it is self-limiting in the worst case.
Could the next round wait for the frames of this round to be sent? For example, `snapshotRound` could queue a marker task on the scheduler after its frames and schedule the next round from there, or it could skip a round while frames are still pending (an `AtomicInteger` counted down in `send`).
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-25197: camel-cli-connector - do not let a slow status starve the WebSocket heartbeat [camel]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #27279:
URL: https://github.com/apache/camel/pull/27279#issuecomment-5952381180
<!-- ci-tested-modules -->
:test_tube: **CI tested the following changed modules:**
- `dsl/camel-cli-connector`
---
<details><summary>:microscope: Scalpel shadow comparison — Scalpel: 8 of 698 tested, 9 compile-only — current: 8 all tested</summary>
[Maveniverse Scalpel](https://github.com/maveniverse/scalpel) detected **8 affected modules** (current approach: 8).
**Skip-tests mode would test 8 modules** (1 direct + 7 downstream), **skip tests for 9** (generated code, meta-modules)
<details><summary>Modules Scalpel would test (8)</summary>
- `camel-cli-connector` ← dsl/camel-cli-connector/src/main/java/org/apache/camel/cli/connector/CliSnapshotProducer.java, dsl/camel-cli-connector/src/main/java/org/apache/camel/cli/connector/LocalCliConnector.java, dsl/camel-cli-connector/src/main/java/org/apache/camel/cli/connector/WebSocketCliConnectorTransport.java
- `camel-cli-debug` ← downstream of org.apache.camel:camel-cli-connector
- `camel-jbang-mcp` ← downstream of org.apache.camel:camel-jbang-core
- `camel-jbang-plugin-mcp` ← downstream of org.apache.camel:camel-jbang-core
- `camel-jbang-plugin-route-parser` ← downstream of org.apache.camel:camel-jbang-core
- `camel-jbang-plugin-tui` ← downstream of org.apache.camel:camel-jbang-core
- `camel-jbang-plugin-validate` ← downstream of org.apache.camel:camel-jbang-core
- `camel-launcher-container` ← downstream of org.apache.camel:camel-launcher
</details>
<details><summary>Modules with tests skipped (9)</summary>
- `camel-jbang-core`
- `camel-jbang-it`
- `camel-jbang-main`
- `camel-jbang-plugin-edit`
- `camel-jbang-plugin-generate`
- `camel-jbang-plugin-kubernetes`
- `camel-jbang-plugin-test`
- `camel-launcher`
- `coverage`
</details>
> :information_source: Shadow mode — Scalpel observes but does not affect test execution. [Learn more](https://github.com/maveniverse/scalpel)
</details>
<details><summary>All tested modules (17 modules, 3m 2s total)</summary>
**Total reactor time:** 3m 2s
| Module | Duration | Status |
| --- | --- | --- |
| Camel :: Launcher | 48.7s | SUCCESS |
| Camel :: JBang :: MCP | 41.5s | SUCCESS |
| Camel :: DSL :: CLI Connector | 31.6s | SUCCESS |
| Camel :: JBang :: Plugin :: Kubernetes | 22.7s | SUCCESS |
| Camel :: JBang :: Plugin :: Testing | 11.0s | SUCCESS |
| Camel :: JBang :: Plugin :: Validate | 8.5s | SUCCESS |
| Camel :: Coverage | 4.8s | SUCCESS |
| Camel :: JBang :: Plugin :: Generate | 3.8s | SUCCESS |
| Camel :: JBang :: Plugin :: Edit | 1.8s | SUCCESS |
| Camel :: DSL :: CLI Debug | 1.7s | SUCCESS |
| Camel :: JBang :: Plugin :: Route Parser | 1.6s | SUCCESS |
| Camel :: JBang :: Plugin :: MCP | 1.4s | SUCCESS |
| Camel :: JBang :: Main | 1.3s | SUCCESS |
| Camel :: JBang :: Integration tests | 1.0s | SUCCESS |
| Camel :: Launcher :: Container | 0.8s | SUCCESS |
| Camel :: JBang :: Core | n/a | |
| Camel :: JBang :: Plugin :: TUI | n/a | |
**Top 20 slowest modules:**
- `Camel :: Launcher` (48.7s)
- `Camel :: JBang :: MCP` (41.5s)
- `Camel :: DSL :: CLI Connector` (31.6s)
- `Camel :: JBang :: Plugin :: Kubernetes` (22.7s)
- `Camel :: JBang :: Plugin :: Testing` (11.0s)
- `Camel :: JBang :: Plugin :: Validate` (8.5s)
- `Camel :: Coverage` (4.8s)
- `Camel :: JBang :: Plugin :: Generate` (3.8s)
- `Camel :: JBang :: Plugin :: Edit` (1.8s)
- `Camel :: DSL :: CLI Debug` (1.7s)
- `Camel :: JBang :: Plugin :: Route Parser` (1.6s)
- `Camel :: JBang :: Plugin :: MCP` (1.4s)
- `Camel :: JBang :: Main` (1.3s)
- `Camel :: JBang :: Integration tests` (1.0s)
- `Camel :: Launcher :: Container` (0.8s)
</details>
---
:gear: [View full build and test results](https://github.com/apache/camel/actions/runs/37004450177)
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-25197: camel-cli-connector - do not let a slow status starve the WebSocket heartbeat [camel]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #27279:
URL: https://github.com/apache/camel/pull/27279#issuecomment-5951932658
:star2: Thank you for your contribution to the Apache Camel project! :star2:
:robot: CI automation will test this PR automatically.
:camel: Apache Camel Committers, please review the following items:
* First-time contributors **require MANUAL approval** for the GitHub Actions to run
* You can use the command `/component-test (camel-)component-name1 (camel-)component-name2..` to request a test from the test bot although they are normally detected and executed by CI.
* You can label PRs using `skip-tests` and `test-dependents` to fine-tune the checks executed by this PR.
* Build and test logs are available in the summary page. **Only** [Apache Camel committers](https://camel.apache.org/community/team/#committers) have access to the summary.
:warning: Be careful when sharing logs. Review their contents before sharing them publicly.
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-25197: camel-cli-connector - do not let a slow status starve the WebSocket heartbeat [camel]
Posted by "Croway (via GitHub)" <gi...@apache.org>.
Croway commented on code in PR #27279:
URL: https://github.com/apache/camel/pull/27279#discussion_r4165878340
##########
dsl/camel-cli-connector/src/main/java/org/apache/camel/cli/connector/WebSocketCliConnectorTransport.java:
##########
@@ -94,12 +94,15 @@ public class WebSocketCliConnectorTransport extends ServiceSupport implements Cl
private CliWebSocketClient client;
private ThreadPoolExecutor actions;
private ScheduledExecutorService scheduler;
+ // collects snapshots: the status of a large integration can take seconds, which must not hold up the scheduler
+ // (heartbeats, sends); snapshots are handed to the scheduler to be sent
+ private ScheduledExecutorService collector;
// fields below are only used from the scheduler thread, except the volatile ones
Review Comment:
Done in 3a5caeffdaa2: the class javadoc now describes the three threads (actions, collector, scheduler), and the field comments say which fields the collector owns (`snapshotFuture`, `debugFuture`, `ticks`, and `lastTraceUid` / `lastReceiveUid` / `lastSent` on `Connection`).
_Claude Code on behalf of Croway_
##########
dsl/camel-cli-connector/src/main/java/org/apache/camel/cli/connector/WebSocketCliConnectorTransport.java:
##########
@@ -491,7 +521,8 @@ private void sendSnapshot(Connection c, String kind, JsonObject data) {
JsonObject frame = envelope("snapshot");
frame.put("kind", kind);
frame.put("data", data);
- send(c, frame);
+ // only the scheduler sends, one frame at a time
+ execute(() -> send(c, frame));
Review Comment:
Done in 3a5caeffdaa2 with the marker approach: `snapshotRound` queues a task on the scheduler behind the frames of its round, and only that task schedules the next round (back on the collector). So a round starts only after the previous round's frames were sent. A round counter, bumped by `scheduleSnapshots`, keeps `updateDelay` from starting a second chain.
_Claude Code on behalf of Croway_
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-25197: camel-cli-connector - do not let a slow status starve the WebSocket heartbeat [camel]
Posted by "Croway (via GitHub)" <gi...@apache.org>.
Croway commented on PR #27279:
URL: https://github.com/apache/camel/pull/27279#issuecomment-5952775326
Thanks @davsclaus, all addressed in 3a5caeffdaa2:
1. Regression test `keepsTheConnectionWhileASlowStatusIsCollected`: a status that takes 2 s, a 200 ms heartbeat; `hello` must arrive within 1.5 s and the client must stay on its first connection for 6 s. Without the fix it fails (`hello` after 2.2 s, reconnect after about 6 s).
2. Comments updated (inline reply).
3. Backpressure: the next round waits for the previous round's frames to be sent (inline reply).
4. Debug snapshot: added a comment that it shares the collector with the status (not a regression, as you say).
5. PR description now notes that the first status no longer comes with `hello`.
Agreed on the file transport: same root cause without the heartbeat symptom, best fixed at the source by CAMEL-25267.
_Claude Code on behalf of Croway_
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org