File tree Expand file tree Collapse file tree
activemq-unit-tests/src/test/java/org/apache/activemq/network Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -165,8 +165,15 @@ public void onMessage(Message message) {
165165 assertTrue (Wait .waitFor (new Condition () {
166166 @ Override
167167 public boolean isSatisified () throws Exception {
168- // The number of message that remain is due to the exclude queue
169- return receivedMessages .size () == MESSAGE_COUNT ;
168+ // Check if messages arrived at the consumer
169+ boolean messagesReceived = receivedMessages .size () == MESSAGE_COUNT ;
170+
171+ // Check if the asynchronous broker statistics have settled
172+ long localDequeues = localBroker .getDestination (includedDestination ).getDestinationStatistics ().getDequeues ().getCount ();
173+ long remoteEnqueues = remoteBroker .getDestination (includedDestination ).getDestinationStatistics ().getEnqueues ().getCount ();
174+
175+ // The test can only proceed when BOTH the messages are received and the stats match
176+ return messagesReceived && localDequeues == MESSAGE_COUNT && remoteEnqueues == MESSAGE_COUNT ;
170177 }
171178 }, 30000 , 500 ));
172179
You can’t perform that action at this time.
0 commit comments