allthingssecurity opened a new pull request, #30625: URL: https://github.com/apache/camel/pull/30625
# Description [CAMEL-27333](https://issues.apache.org/jira/browse/CAMEL-27333) Related to [CAMEL-27321](https://issues.apache.org/jira/browse/CAMEL-27321) (the reply manager stop completes every request, separate PR). This one touches another class (`TemporaryQueueReplyManager`), does not depend on it, and the two merge in either order. With a temporary reply queue, when the connection of the reply listener fails, `TemporaryReplyQueueExceptionListener` marks the temporary queue for a refresh. Every InOut request then waits in `getReplyTo()` (`TemporaryReplyQueueDestinationResolver.destinationReady`) until the connection recovery of the listener container creates the new temporary queue. That wait was `condition.await()` with no timeout: - when the producer is stopped during the wait, the listener container stops and cancels its recovery, and nothing signals the condition: the request thread waits for ever, with the JMS connection and session that `SjmsTemplate.send` opened, and its exchange never completes (a `ProducerTemplate.request` blocks for ever, the exchange stays in flight). The request is not registered yet, so neither its request timeout nor the stop of the reply manager (CAMEL-27321) can complete it; - until the recovery has created the new temporary queue, every InOut request blocks in that wait, even when the broker is reachable again (the recovery starts 1 s after the failure and then retries every `recoveryInterval`, 5 s by default), instead of failing after its request timeout. (While the broker cannot be reached at all, the producer usually fails earlier, when it opens its own connection for the send.) The await also had no loop, so a spurious wakeup let a request go on with the old temporary queue. This change (`TemporaryQueueReplyManager`): - `destinationReady(timeout)` waits in a loop while the refresh is wanted, at most the request timeout of the endpoint (`requestTimeout`; 0 or less waits until the queue is refreshed or the reply manager stops). It returns `false` when the time runs out or the reply manager is stopped. - `getReplyTo()` then throws an `IllegalStateException` that says which case it was. `SjmsProducer` completes the exchange with it; the request is not registered and not sent. - `doStop()` stops the resolver (sets the flag and signals the waiters under its lock) before the listener container is stopped. The wait uses the endpoint's `requestTimeout`, as `getReplyTo()` does not get the exchange; a `CamelJmsRequestTimeout` header on the exchange is not used for this wait. Model: found with a TLA+ model of the sjms request/reply (producers, correlation map, timeout checker, reply listener with connection failures and recovery, producer stop). I extended it with the fix (the model includes the CAMEL-27321 change; the wait does not depend on it). On main a request waits for ever after a stop (invariant and liveness). With the fix: every request that waits for the new queue leaves the wait (liveness, with and without a deadline); a request that fails here is completed once and was neither registered nor sent; no request fails while the recovery has already created the queue. 3 producers, 2 connection failures: 1,715,338 distinct states (TLC and everystate agree). Tests: new `TemporaryQueueReplyManagerRefreshTest` (embedded Artemis, as the module's other tests): - a request waits for the new temporary queue and the producer is stopped (requestTimeout 60 s): the request must complete within 5 s, with the exception; - a request waits for the new temporary queue and no recovery comes (requestTimeout 1 s): the request must fail after its request timeout; - the connection fails and the recovery creates the new queue: the request is sent, and times out as usual (control, passes on main). On main the first two fail (the request is still waiting after 5 s and after 10 s); the control passes. With the change, on main, the unit tests of camel-sjms pass: 229 run, 0 failures, 5 skipped (also on top of the CAMEL-27321 branch: 234 run, 0 failures). The new class 20 times in one JVM: 60 run, 0 failures, and 10 more times on main: 30 run, 0 failures. (A first version of the control used a request timeout of 1 s, the same as the fixed initial delay of the connection recovery, and failed 11 of 20 runs, as the request then fails before the new queue exists; it now uses 3 s.) Behaviour change: when the recovery of the connection takes longer than the request timeout, a request now fails after its request timeout instead of waiting for the recovery. The request timeout is the time the caller is willing to wait for the reply, so I think this is the expected result, but it is a change for endpoints with a request timeout shorter than the recovery (the recovery starts after 1 s and retries every `recoveryInterval`, 5 s by default). # 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-27333](https://issues.apache.org/jira/browse/CAMEL-27333). # 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]
