allthingssecurity opened a new pull request, #27390:
URL: https://github.com/apache/camel/pull/27390

   # Description
   
   [CAMEL-25314](https://issues.apache.org/jira/browse/CAMEL-25314)
   
   `CxfConsumer` and `CxfRsConsumer` implement `Suspendable` (CAMEL-12870), so 
the graceful shutdown suspends them and keeps the CXF server running while the 
requests in flight complete. But they have no suspend logic and their invokers 
never check the status, so a suspended consumer keeps accepting and routing new 
requests: a graceful shutdown under a steady flow of requests only ends at the 
shutdown timeout (and then forces the requests in flight), and suspending the 
route (route controller, JMX, `ThrottlingInflightRoutePolicy`, 
`ThrottlingExceptionRoutePolicy`) holds nothing back.
   
   This change rejects a new invocation (synchronous, or a continuation that 
`isNew()`) with HTTP status 503 while the consumer is suspending or suspended, 
like the HTTP consumers (servlet, jetty, undertow, netty-http, platform-http) 
do: `CxfConsumer` throws a `Fault` with status code 503 (CXF logs it at WARN 
with its stack trace, as it logs every fault that is not a declared one), 
`CxfRsInvoker` returns a 503 `Response` (no exception, so nothing is logged 
above DEBUG). `CxfRsInvoker` does not look up the continuation for the 
invocation of a sub resource locator, as before (the method of the sub resource 
is invoked next and checked then; a second lookup would start the async context 
of the servlet request again). A resumed continuation belongs to a request in 
flight and still completes, which keeps the purpose of CAMEL-12870 (which only 
added `implements Suspendable`).
   
   The defect was found with a TLA+ model of the consumer under a graceful 
shutdown or route suspend with synchronous and asynchronous requests: "a 
suspended consumer takes no new work" is violated in 3 steps (suspend, a 
request arrives and is admitted); "the consumer is only stopped when nothing is 
inflight" holds before and after the fix; and rejecting resumed continuations 
too would lose the responses of the requests in flight, which is why the fix 
only checks new invocations.
   
   Upgrade guide: new subsection `==== A suspended consumer rejects new 
requests` under the existing `=== camel-cxf` section.
   
   Tests: new `CxfConsumerSuspendTest` (camel-cxf-soap) and 
`CxfRsConsumerSuspendTest` (camel-cxf-rest); latches and Awaitility. Without 
the main-code change:
   ```
   CxfConsumerSuspendTest.testSuspendedRouteRejectsRequests:79 A suspended 
route must not accept a request ==> Expected java.lang.Exception to be thrown, 
but nothing was thrown.
   
CxfConsumerSuspendTest.testGracefulStopCompletesInflightAndRejectsNewRequests:112
 A request received while stopping must be rejected ==> Expected 
java.lang.Exception to be thrown, but nothing was thrown.
   CxfRsConsumerSuspendTest.testSuspendedRouteRejectsRequests:77 A suspended 
route must answer 503 ==> expected: <503> but was: <200>
   
CxfRsConsumerSuspendTest.testGracefulStopCompletesInflightAndRejectsNewRequests:105
 A request received while stopping must be rejected ==> expected: <503> but 
was: <200>
   ```
   The graceful-stop tests also check that the request in flight (asynchronous: 
its continuation resumes after the suspend) gets its response. With the change 
the camel-cxf-soap (168 tests, 2 skipped), camel-cxf-rest (51), 
camel-cxf-spring-soap (161, 3 skipped) and camel-cxf-spring-rest (111, 
including the sub resource tests of `CxfRsRouterTest`) suites pass.
   
   # 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).
   
   # 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 and tested the affected modules, including the formatter and 
import-sort plugins. 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]

Reply via email to