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

   BatchConsumerReconnectTest failed intermittently in different tests (batch 
sizes of 3 instead of 5 or 4, unexpected mock message counts), and the Surefire 
reruns of a failed test then always failed with "AMQ219007: Cannot connect to 
server(s)".
   
   Causes and fixes:
   
   - testReconnectSessionTransacted and testReconnectClientAcknowledge sent 2 
messages and immediately simulated a connection failure, without waiting for 
the batch consumer to receive them. Messages not yet received were not part of 
the buffered batch, so the first batch after the reconnect had fewer messages 
than expected. Wait until both messages have been received before triggering 
the failure, as already done for testReconnectAutoAcknowledge (CAMEL-26369).
   
   - The session-tx and client-ack routes used a 1000 ms batch interval, so a 
batch could be completed by the timer instead of by size, depending on how long 
the reconnection took on a slow machine. Use a 60 s interval for these routes 
so batches are only completed by size. As a consequence 
testReconnectSessionTransacted now sends 8 messages after the reconnect and 
expects two complete batches of 5, as an incomplete batch can no longer be 
flushed by the timer. The auto-ack route keeps the 1000 ms interval as its test 
relies on it for an incomplete batch.
   
   - AbstractArtemisEmbeddedService.initialize() reused the stopped 
EmbeddedActiveMQ (and its ActiveMQServer and in-VM acceptor) when the service 
was started again, which is what happens when Surefire reruns a failed test in 
the same JVM (afterAll stops the broker, beforeAll initializes it again). A new 
broker id, hence a new vm:// address, is computed on each initialization but 
the stopped server still had the previous acceptor, so nothing was listening on 
the new address. Create a new EmbeddedActiveMQ and Configuration when the 
previous server has been stopped.
   
   How it was verified:
   - Making a test fail on its first attempt (temporary, not committed) and 
running with -Dsurefire.rerunFailingTestsCount=2: before the fix the reruns 
failed with AMQ219007, after the fix the rerun passes (Flakes: 1).
   - BatchConsumerReconnectTest and BatchConsumerStopStartTest pass.
   - The original race conditions could not be reproduced locally.
   
   Co-authored-by: IBM Bob 2.2.1
   
   # Description
   
   <!--
   - Write a pull request description that is detailed enough to understand 
what the pull request does, how, and why.
   -->
   
   # Target
   
   - [ ] I checked that the commit is targeting the correct branch (Camel 4 
uses the `main` branch)
   
   # Tracking
   - [ ] 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).
   
   <!--
   # *Note*: trivial changes like, typos, minor documentation fixes and other 
small items do not require a JIRA issue. In this case your pull request should 
address just this issue, without pulling in other changes.
   -->
   
   # Apache Camel coding standards and style
   
   - [ ] I checked that each commit in the pull request has a meaningful 
subject line and body.
   
   <!--
   If you're unsure, you can format the pull request title like `[CAMEL-XXX] 
Fixes bug in camel-file component`, where you replace `CAMEL-XXX` with the 
appropriate JIRA issue.
   -->
   
   - [ ] I have run `mvn clean install -DskipTests` locally from root folder 
and I have committed all auto-generated changes.
   
   <!--
   You can run the aforementioned command in your module so that the build 
auto-formats your code. This will also be verified as part of the checks and 
your PR may be rejected if if there are uncommited changes after running `mvn 
clean install -DskipTests`.
   
   You can learn more about the contribution guidelines at 
https://github.com/apache/camel/blob/main/CONTRIBUTING.md
   -->
   
   # AI-assisted contributions
   
   - [ ] 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 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