NO-JIRA Fix AnycastTest.testTxCommitReceive random failure

This commit is contained in:
Howard Gao 2024-08-18 19:34:04 +08:00 committed by Robbie Gemmell
parent 87cc15700f
commit c395db526c
1 changed files with 9 additions and 0 deletions

View File

@ -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++) {