allthingssecurity opened a new pull request, #30468: URL: https://github.com/apache/camel/pull/30468
# Description [CAMEL-27217](https://issues.apache.org/jira/browse/CAMEL-27217) `VertxPlatformHttpConsumer` runs the route in `vertx.executeBlocking` with the synchronous `getProcessor().process(exchange)`, so the worker thread waits (in the `AsyncProcessorAwaitManager`) until the whole route is done. The vertx-http producer is asynchronous: it sends the request and, when the response arrives on the event loop, completes the exchange in `vertx.executeBlocking` too (on a worker thread, as the binding and the rest of the route may block). When both use the same Vert.x (a `Vertx` in the registry, which both `VertxPlatformHttpServer` and `VertxHttpComponent` use, as in Camel Quarkus), a route `from("platform-http:/x").to("vertx-http:...")` with as many requests in flight as worker threads (20 by default in Vert.x) hangs for good: every worker thread waits for its route, and the completion of every vertx-http call waits for a free worker thread. No request is answered again, also after the load is gone, and the only trace is the blocked-thread warnings of Vert.x. The vertx-http `timeout` does not help (its failure is completed the same way), and the platform-http `requestTimeout` answers 503 while the worker threads stay blocked. A backend that slows down for a moment (more requests in flight) is enough. Fix: the consumer still starts the route on a worker thread, as the first steps of the route may block (the reason for `executeBlocking`, see the comment in `handleRequest`), but with the asynchronous processor. When the route continues on another thread, the worker thread is free at once; when the route is done, a promise is completed on the context of the request, and the response is written from there, as before (the `executeBlocking` future completed on the same context). A route that is synchronous to its end behaves as before: it runs on the worker thread and completes before `executeBlocking` returns. An exception thrown by the start of the route still fails the request as before. Model: a small TLA+ model (`SharedWorkerPool.tla`: W worker threads, requests whose route sends an http call and whose completion needs a worker thread) checks "every request completes". With the synchronous processor TLC reports a deadlock for 2 requests and 2 worker threads; with the asynchronous processor it holds (16 distinct states). Tests: `VertxPlatformHttpSharedVertxWorkerPoolTest`: a Vert.x with 2 worker threads in the registry, a route platform-http -> vertx-http (with `removeHeaders("CamelHttp*")`, so it calls the backend uri) to a local backend (JDK `HttpServer`) that answers once both requests have arrived, so each request holds a worker thread meanwhile on main: both requests must be answered. On main the test fails: neither request is answered (the HTTP client times out after 10 seconds). With the change it passes, and the camel-platform-http-vertx tests pass (175 run, 0 failures, 1 skipped as on main). The new class 20 times in one JVM: 20 run, 0 failures. What else changes: the steps of the route run on the same threads as before (the route already continued on the thread that completed an asynchronous step; only the worker thread that waited for it is freed), and the response is still written on the context of the request. A route with an asynchronous step no longer holds a worker thread per request, so the worker pool no longer bounds the number of such requests in flight: they all reach the asynchronous step (for example the backend of a vertx-http call) instead of queueing for a worker thread. A route that needs a bound sets one itself (Throttle EIP, the limits of the server). The 4.24 upgrade guide has a short entry about this (section "camel-platform-http-vertx - a route with an asynchronous step no longer holds a worker thread"). Not changed: `KnativeHttpConsumer` and `VertxWebsocketConsumer` call the synchronous processor inside `executeBlocking` the same way (follow-up if wanted). # Target - [x] I checked that the commit is targeting the correct branch (Camel 4 uses the `main` branch) # Tracking - [x] If this is a large change, bug fix, or code improvement, I checked there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for the change (usually before you start working on it): [CAMEL-27217](https://issues.apache.org/jira/browse/CAMEL-27217). # Apache Camel coding standards and style - [x] I checked that each commit in the pull request has a meaningful subject line and body. - [ ] I have run `mvn clean install -DskipTests` locally from root folder and I have committed all auto-generated changes. (I built the touched module with the formatter and import-sort plugins; no option, doc or generated file changes. I did not run the full root build.) # AI-assisted contributions - [x] If this PR includes AI-generated code, commits have proper co-authorship attribution (e.g., `Co-authored-by` trailers) and the PR description identifies the AI tool used. This PR was prepared with Claude Code (Claude Opus 5.5). The commit carries a `Co-Authored-By` trailer. _Claude Code on behalf of allthingssecurity_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- 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]
