NO-JIRA Fix QueueImplTest#testRoundRobinWithQueueing

This test fails occasionally because the queue's delivering thread
may interference with the consumer's iterator during consumers adding.
The result is that the first of the 2 consumers may get iterated
twice and therefore the messages received by the 2 consumers are
not even.

Tha change puts the message add after the consumer add so that
the delivering thread only kicks off after consumers are all added
and messages should be evenly distributed to both consumers.
This commit is contained in:
Howard Gao 2019-03-15 12:05:23 +08:00
parent fc556c98ee
commit 70e3888910
1 changed files with 8 additions and 8 deletions

View File

@ -584,14 +584,6 @@ public class QueueImplTest extends ActiveMQTestBase {
// Test first with queueing
for (int i = 0; i < numMessages; i++) {
MessageReference ref = generateReference(queue, i);
refs.add(ref);
queue.addTail(ref);
}
FakeConsumer cons1 = new FakeConsumer();
FakeConsumer cons2 = new FakeConsumer();
@ -600,6 +592,14 @@ public class QueueImplTest extends ActiveMQTestBase {
queue.addConsumer(cons2);
for (int i = 0; i < numMessages; i++) {
MessageReference ref = generateReference(queue, i);
refs.add(ref);
queue.addTail(ref);
}
queue.resume();
// Need to make sure the consumers will receive the messages before we do these assertions