Search in sources :

Example 21 with PageSubscription

use of org.apache.activemq.artemis.core.paging.cursor.PageSubscription in project activemq-artemis by apache.

the class PageCursorStressTest method testMultipleIterators.

@Test
public void testMultipleIterators() throws Exception {
    final int NUM_MESSAGES = 10;
    int numberOfPages = addMessages(NUM_MESSAGES, 1024 * 1024);
    System.out.println("NumberOfPages = " + numberOfPages);
    PageCursorProvider cursorProvider = lookupCursorProvider();
    PageSubscription cursor = cursorProvider.getSubscription(queue.getID());
    LinkedListIterator<PagedReference> iter = cursor.iterator();
    LinkedListIterator<PagedReference> iter2 = cursor.iterator();
    assertTrue(iter.hasNext());
    PagedReference msg1 = iter.next();
    PagedReference msg2 = iter2.next();
    assertEquals(tstProperty(msg1.getMessage()), tstProperty(msg2.getMessage()));
    System.out.println("property = " + tstProperty(msg1.getMessage()));
    msg1 = iter.next();
    assertEquals(1, tstProperty(msg1.getMessage()));
    iter.remove();
    msg2 = iter2.next();
    assertEquals(2, tstProperty(msg2.getMessage()));
    iter2.repeat();
    msg2 = iter2.next();
    assertEquals(2, tstProperty(msg2.getMessage()));
    iter2.repeat();
    assertEquals(2, tstProperty(msg2.getMessage()));
    msg1 = iter.next();
    assertEquals(2, tstProperty(msg1.getMessage()));
    iter.repeat();
    msg1 = iter.next();
    assertEquals(2, tstProperty(msg1.getMessage()));
    assertTrue(iter2.hasNext());
}
Also used : PagedReference(org.apache.activemq.artemis.core.paging.cursor.PagedReference) PageSubscription(org.apache.activemq.artemis.core.paging.cursor.PageSubscription) PageCursorProvider(org.apache.activemq.artemis.core.paging.cursor.PageCursorProvider) Test(org.junit.Test)

Example 22 with PageSubscription

use of org.apache.activemq.artemis.core.paging.cursor.PageSubscription in project activemq-artemis by apache.

the class PagingCounterTest method locateCounter.

/**
 * @param queue
 * @return
 * @throws Exception
 */
private PageSubscriptionCounter locateCounter(Queue queue) throws Exception {
    PageSubscription subscription = server.getPagingManager().getPageStore(new SimpleString("A1")).getCursorProvider().getSubscription(queue.getID());
    PageSubscriptionCounter counter = subscription.getCounter();
    return counter;
}
Also used : SimpleString(org.apache.activemq.artemis.api.core.SimpleString) PageSubscriptionCounter(org.apache.activemq.artemis.core.paging.cursor.PageSubscriptionCounter) PageSubscription(org.apache.activemq.artemis.core.paging.cursor.PageSubscription)

Aggregations

PageSubscription (org.apache.activemq.artemis.core.paging.cursor.PageSubscription)22 Test (org.junit.Test)10 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)8 PagedReference (org.apache.activemq.artemis.core.paging.cursor.PagedReference)8 Message (org.apache.activemq.artemis.api.core.Message)6 StorageManager (org.apache.activemq.artemis.core.persistence.StorageManager)6 ArrayList (java.util.ArrayList)5 Filter (org.apache.activemq.artemis.core.filter.Filter)5 Transaction (org.apache.activemq.artemis.core.transaction.Transaction)5 HashMap (java.util.HashMap)4 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)4 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)4 ActiveMQBuffer (org.apache.activemq.artemis.api.core.ActiveMQBuffer)4 PageCursorProvider (org.apache.activemq.artemis.core.paging.cursor.PageCursorProvider)4 PostOffice (org.apache.activemq.artemis.core.postoffice.PostOffice)4 ActiveMQServer (org.apache.activemq.artemis.core.server.ActiveMQServer)4 LargeServerMessage (org.apache.activemq.artemis.core.server.LargeServerMessage)4 QueueConfig (org.apache.activemq.artemis.core.server.QueueConfig)4 HierarchicalRepository (org.apache.activemq.artemis.core.settings.HierarchicalRepository)4 ExecutorFactory (org.apache.activemq.artemis.utils.ExecutorFactory)4