Search in sources :

Example 21 with FakeConsumer

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());
}
Also used : FakeConsumer(org.apache.activemq.artemis.tests.unit.core.server.impl.fakes.FakeConsumer) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) QueueImpl(org.apache.activemq.artemis.core.server.impl.QueueImpl) Test(org.junit.Test)

Aggregations

QueueImpl (org.apache.activemq.artemis.core.server.impl.QueueImpl)21 FakeConsumer (org.apache.activemq.artemis.tests.unit.core.server.impl.fakes.FakeConsumer)21 Test (org.junit.Test)20 MessageReference (org.apache.activemq.artemis.core.server.MessageReference)18 ArrayList (java.util.ArrayList)16 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)6 Filter (org.apache.activemq.artemis.core.filter.Filter)3 FakeFilter (org.apache.activemq.artemis.tests.unit.core.server.impl.fakes.FakeFilter)3 Consumer (org.apache.activemq.artemis.core.server.Consumer)2 LinkedList (java.util.LinkedList)1 CountDownLatch (java.util.concurrent.CountDownLatch)1