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

   # Description
   
   Fixes the flaky integration test 
`ActiveMQConsumeWildcardQueuesIT.testWildcard` in `camel-jms`, reported in 
[CAMEL-27105](https://issues.apache.org/jira/browse/CAMEL-27105) (Develocity 
recorded it flaky 76 times in 7 days).
   
   **Root cause** (confirmed via local reproduction with full broker-level 
Artemis logging — see the JIRA comment for the detailed investigation, 
including exact timestamps): a one-time startup race on the embedded Artemis 
broker between the route's wildcard JMS consumer queue 
(`activemq:queue:sport.#`) registering, and the test's very first send creating 
a brand-new concrete address. If the address is created a few milliseconds 
before the wildcard queue finishes registering, Artemis does not retroactively 
bind that address to the wildcard queue, so the message is delivered only to 
its own private auto-created queue and never reaches the wildcard consumer. 
Once the wildcard queue exists, every subsequent new address binds to it 
correctly and instantly — it's a one-time startup race, not an ongoing 
per-message one.
   
   This looks like a defect in Apache ActiveMQ Artemis itself: JMS 
point-to-point semantics guarantee a queued message is retained until consumed 
regardless of producer/consumer timing, and wildcard queue consumption is a 
broker-side convenience whose value depends on preserving that guarantee. A 
report against Apache ActiveMQ Artemis will follow separately; this PR only 
addresses the test-side symptom.
   
   **Fix:** before sending the real test messages, send a throwaway warm-up 
probe to a dedicated address and wait (via `NotifyBuilder`, up to 3 seconds) 
for it to round-trip through the wildcard consumer, confirming the binding is 
live. If the probe itself loses the race and the wait times out, an INFO log 
line notes it; by then, more time has passed than the registration should ever 
need, so the real sends that follow are safe either way. No `Thread.sleep()`, 
no production code changes.
   
   **Test plan:**
   - Reproduced the original flakiness locally (repeated runs of the full 
`camel-jms` IT suite with full broker-level logging enabled).
   - Verified the fix locally, including the fallback path itself (confirmed 
the test still passes correctly even when the warm-up probe loses the race and 
the wait times out).
   
   # Target
   
   - [x] I checked that the commit is targeting the correct branch (Camel 4 
uses the `main` branch)
   
   # Tracking
   
   - [x] JIRA issue filed: 
[CAMEL-27105](https://issues.apache.org/jira/browse/CAMEL-27105)
   
   # 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. *(Test-only change in a single 
file with no catalog/doc generation impact; instead ran `mvn formatter:format 
impsort:sort` scoped to `camel-jms` and the actual integration test itself, 
which passes.)*
   
   # 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](https://claude.com/claude-code); the 
commit carries a `Co-authored-by` trailer accordingly.
   
   ---
   
   _Claude Code on behalf of Torsten Mielke_
   
   🤖 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