final int NUM_MESSAGES = 100;
PageCursorProvider cursorProvider = lookupCursorProvider();
PageSubscription cursor = cursorProvider.createSubscription(11, null, false);
PageSubscriptionImpl cursor2 = (PageSubscriptionImpl)cursorProvider.createSubscription(12, null, false);
this.queueList.add(new FakeQueue(new SimpleString("a"), 11));
this.queueList.add(new FakeQueue(new SimpleString("b"), 12));
int numberOfPages = addMessages(NUM_MESSAGES, 1024 * 1024);
System.out.println("NumberOfPages = " + numberOfPages);
queue.getPageSubscription().close();
PagedReference msg;
LinkedListIterator<PagedReference> iterator = cursor.iterator();
LinkedListIterator<PagedReference> iterator2 = cursor2.iterator();
cursor2.bookmark(new PagePositionImpl(1, -1));
int key = 0;
while ((msg = iterator.next()) != null)
{
System.out.println("key = " + key);
assertEquals(key++, msg.getMessage().getIntProperty("key").intValue());
cursor.ack(msg);
}
assertEquals(NUM_MESSAGES, key);
forceGC();
for (int i = 0; i < 10; i++)
{
assertTrue(iterator2.hasNext());
msg = iterator2.next();
assertEquals(i, msg.getMessage().getIntProperty("key").intValue());
}
assertSame(cursor2.getProvider(), cursorProvider);
cursor2.close();
lookupPageStore(ADDRESS).flushExecutors();
server.stop();
createServer();