diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PagingSendTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PagingSendTest.java index 5f736fc678..f913dca5c1 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PagingSendTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PagingSendTest.java @@ -233,6 +233,9 @@ public class PagingSendTest extends ActiveMQTestBase { Queue queue = server.locateQueue(queueAddr); + // Give time Queue.deliverAsync to deliver messages + Assert.assertTrue("Messages were not propagated to internal structures.", waitForMessages(queue, batchSize, 3000)); + checkBatchMessagesAreNotPagedTwice(queue); for (int i = 0; i < 10; i++) { @@ -324,6 +327,18 @@ public class PagingSendTest extends ActiveMQTestBase { assertTrue(duplicates == 0); } + public boolean waitForMessages(Queue queue, int count, long timeout) throws Exception { + long timeToWait = System.currentTimeMillis() + timeout; + + while (System.currentTimeMillis() < timeToWait) { + if (queue.getMessageCount() >= count) { + return true; + } + Thread.sleep(100); + } + return false; + } + /** * checks that there are no message duplicates in the page. Any IDs found in the ignoreIds field will not be tested * this allows us to test only those messages that have been sent after the address has started paging (ignoring any