int numberOfPages = addMessages(NUM_MESSAGES, 100 * 1024);
System.out.println("Number of pages = " + numberOfPages);
PageCursorProvider cursorProvider = lookupCursorProvider();
PageSubscription cursor = this.server.getPagingManager()
.getPageStore(ADDRESS)
.getCursorProvier()
.getSubscription(queue.getID());
PageCache firstPage = cursorProvider.getPageCache(new PagePositionImpl(server.getPagingManager()
.getPageStore(ADDRESS)
.getFirstPage(), 0));
int firstPageSize = firstPage.getNumberOfMessages();
firstPage = null;
System.out.println("Cursor: " + cursor);
cursorProvider.printDebug();
LinkedListIterator<PagedReference> iterator = cursor.iterator();
for (int i = 0; i < 1000; i++)
{
System.out.println("Reading Msg : " + i);
PagedReference msg = iterator.next();
assertNotNull(msg);
assertEquals(i, msg.getMessage().getIntProperty("key").intValue());
if (i < firstPageSize)
{
cursor.ack(msg);
}
}
cursorProvider.printDebug();
server.getStorageManager().waitOnOperations();
lookupPageStore(ADDRESS).flushExecutors();
// needs to clear the context since we are using the same thread over two distinct servers