From c395db526c24d55eee4abea7688ce69eb75e810a Mon Sep 17 00:00:00 2001 From: Howard Gao Date: Sun, 18 Aug 2024 19:34:04 +0800 Subject: [PATCH] NO-JIRA Fix AnycastTest.testTxCommitReceive random failure --- .../tests/integration/addressing/AnycastTest.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/addressing/AnycastTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/addressing/AnycastTest.java index 3cb8cb398c..2ecea5a9bf 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/addressing/AnycastTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/addressing/AnycastTest.java @@ -94,11 +94,20 @@ public class AnycastTest extends ActiveMQTestBase { } assertNull(consumer1.receive(200)); assertNull(consumer2.receive(200)); + + // before commit close the consumers because it can trigger delivering count + // that makes getMessageCount temporarily inaccurate. + consumer1.close(); + consumer2.close(); + session.commit(); assertTrue(TimeUtils.waitOnBoolean(true, 2000, () -> num / 2 == q1.getMessageCount())); assertTrue(TimeUtils.waitOnBoolean(true, 2000, () -> num / 2 == q2.getMessageCount())); + consumer1 = session.createConsumer(q1.getName()); + consumer2 = session.createConsumer(q2.getName()); + ClientConsumer[] consumers = new ClientConsumer[]{consumer1, consumer2}; for (int i = 0; i < consumers.length; i++) {