org.apache.activemq.artemis.core.paging.cursor.PagePosition

Here are the examples of the java api class org.apache.activemq.artemis.core.paging.cursor.PagePosition taken from open source projects.

1. PageSubscriptionImpl#moveNextPage()

View license
private PagePosition moveNextPage(final PagePosition pos) {
    PagePosition retPos = pos;
    while (true) {
        retPos = retPos.nextPage();
        synchronized (consumedPages) {
            PageCursorInfo pageInfo = consumedPages.get(retPos.getPageNr());
            // any deleted or complete page will be ignored on the moveNextPage, we will just keep going
            if (pageInfo == null || (!pageInfo.isPendingDelete() && pageInfo.getCompleteInfo() == null)) {
                return retPos;
            }
        }
    }
}

2. PageSubscriptionImpl#internalGetNext()

View license
private PagedReference internalGetNext(final PagePosition pos) {
    PagePosition retPos = pos.nextMessage();
    PageCache cache = cursorProvider.getPageCache(pos.getPageNr());
    if (cache != null && !cache.isLive() && retPos.getMessageNr() >= cache.getNumberOfMessages()) {
        // The next message is beyond what's available at the current page, so we need to move to the next page
        cache = null;
    }
    // it will scan for the next available page
    while ((cache == null && retPos.getPageNr() <= pageStore.getCurrentWritingPage()) || (cache != null && retPos.getPageNr() <= pageStore.getCurrentWritingPage() && cache.getNumberOfMessages() == 0)) {
        retPos = moveNextPage(retPos);
        cache = cursorProvider.getPageCache(retPos.getPageNr());
    }
    if (cache == null) {
        // it will be null in the case of the current writing page
        return null;
    } else {
        PagedMessage serverMessage = cache.getMessage(retPos.getMessageNr());
        if (serverMessage != null) {
            return cursorProvider.newReference(retPos, serverMessage, this);
        } else {
            return null;
        }
    }
}