use of org.apache.activemq.artemis.tests.unit.core.server.impl.fakes.FakeConsumer in project activemq-artemis by apache.
the class QueueConcurrentTest method testConcurrentAddsDeliver.
/*
* Concurrent set consumer not busy, busy then, call deliver while messages are being added and consumed
*/
@Test
public void testConcurrentAddsDeliver() throws Exception {
QueueImpl queue = (QueueImpl) queueFactory.createQueueWith(QueueConfig.builderWith(1, new SimpleString("address1"), new SimpleString("queue1")).durable(false).temporary(false).autoCreated(false).build());
FakeConsumer consumer = new FakeConsumer();
queue.addConsumer(consumer);
final long testTime = 5000;
Sender sender = new Sender(queue, testTime);
Toggler toggler = new Toggler(queue, consumer, testTime);
sender.start();
toggler.start();
sender.join();
toggler.join();
consumer.setStatusImmediate(HandleStatus.HANDLED);
queue.deliverNow();
if (sender.getException() != null) {
throw sender.getException();
}
if (toggler.getException() != null) {
throw toggler.getException();
}
assertRefListsIdenticalRefs(sender.getReferences(), consumer.getReferences());
QueueConcurrentTest.log.info("num refs: " + sender.getReferences().size());
QueueConcurrentTest.log.info("num toggles: " + toggler.getNumToggles());
}
Aggregations