This is an automated email from the ASF dual-hosted git repository.
apupier pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 6cb1ebbb2bb6 CAMEL-26369: camel-sjms - Fix flaky
BatchConsumerReconnectTest.testReconnectAutoAcknowledge
6cb1ebbb2bb6 is described below
commit 6cb1ebbb2bb6746ee2015149abc73e5da5236de4
Author: Aurélien Pupier <[email protected]>
AuthorDate: Wed Oct 28 12:06:33 2026 +0100
CAMEL-26369: camel-sjms - Fix flaky
BatchConsumerReconnectTest.testReconnectAutoAcknowledge
The test sent 2 messages and immediately simulated a connection failure
without waiting for the batch consumer to receive them. With
AUTO_ACKNOWLEDGE, BatchConsumerWorker dispatches already-acknowledged
buffered messages on a connection failure (they cannot be redelivered).
If only 1 of the 2 messages had been received at that point, a batch of
1 was dispatched, failing with "expected: <2> but was: <1>".
Wait until the tracked consumer has received both messages before
triggering the failure, as BatchConsumerStopStartTest already does.
How it was reproduced:
- Running the original test 10 times in a row, and 5 times with all 22
cores saturated by busy loops, did not fail: the race window is tiny
locally.
- Temporarily adding Thread.sleep(300) in BatchConsumerWorker.run()
right after buffer.add(msg) (not committed) widened the window and the
original test then failed deterministically with
"expected: <2> but was: <1>" at BatchConsumerReconnectTest:89.
- With the same temporary sleep, the fixed test passed 3 out of 3 runs.
Co-authored-by: IBM Bob 2.2.1
Signed-off-by: Aurélien Pupier <[email protected]>
---
.../camel/component/sjms/batch/BatchConsumerReconnectTest.java | 5 +++++
1 file changed, 5 insertions(+)
diff --git
a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/batch/BatchConsumerReconnectTest.java
b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/batch/BatchConsumerReconnectTest.java
index 9c8023d3eef6..e022639c519a 100644
---
a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/batch/BatchConsumerReconnectTest.java
+++
b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/batch/BatchConsumerReconnectTest.java
@@ -80,6 +80,11 @@ public class BatchConsumerReconnectTest extends
JmsExclusiveTestSupport {
sendMessagesWithText(template, endpointUri, 2, "Before!");
+ // make sure both messages are buffered by the consumer before
simulating the failure,
+ // otherwise the buffered messages may be dispatched as a partial batch
+ await().atMost(10, TimeUnit.SECONDS)
+ .until(() -> trackedConnectionFactory.messages(queueName) ==
2);
+
int connectionsBefore = trackedConnectionFactory.getCreateCount();
triggerConnectionFailure(context, ROUTE_ID_AUTO_ACK);
await().atMost(30, TimeUnit.SECONDS)