Class DefaultJournalManager

    • Method Detail

      • enqueue

        public long enqueue​(@NonNull JournalEntry entry)
        Description copied from interface: JournalManager
        Adds the given entry to a journal.

        New journal is automatically created if a journal with the given name does not exists.

        Specified by:
        enqueue in interface JournalManager
        Parameters:
        entry - entry to persist
        Returns:
        id generated for the entry
      • peek

        public Iterable<JournalEntry> peek​(@NonNull JournalIdentifier journalId,
                                           int maxEntries)
        Description copied from interface: JournalManager
        Return a copy of journal entries that are waiting to be processed.
        Specified by:
        peek in interface JournalManager
        Parameters:
        journalId - only entries with this journal id will be returned
        maxEntries - maximum number of entries to return
        Returns:
        a copy of journal entries that are waiting to be processed
      • reset

        public void reset​(@NonNull JournalIdentifier journalId)
        Description copied from interface: JournalManager
        Resets the state of the journal so that all entries currently in the journal will be skipped.
        Specified by:
        reset in interface JournalManager
        Parameters:
        journalId - identifier of the journal to reset
      • processNewEntries

        public <V> V processNewEntries​(@NonNull JournalIdentifier journalId,
                                       int maxEntries,
                                       @NonNull Function<Iterable<JournalEntry>,​@NonNull EntryProcessorResult<V>> entryProcessor)
                                throws org.springframework.dao.DataAccessException
        Description copied from interface: JournalManager
        Processes journal entries that were added since the last time this method was called for this journal on this cluster node.

        This method does not return entries that were added immediately before calling this method. Use JournalManager.waitForRecentEntriesToBecomeVisible() for ensuring these entries will be included.

        This method can miss some entries due to identifier assignment and entry insertion not being an atomic operation. The risk of missed entries can be reduced by creating new entries as close to transaction commit as possible.

        If entryProcessor throws an exception, the same entries will be returned again when this method is next called for this journal on this cluster node.

        New journal is automatically created if a journal with the given name does not exists.

        Specified by:
        processNewEntries in interface JournalManager
        Parameters:
        journalId - only entries with this journal id will be returned
        maxEntries - maximum number of entries to process
        entryProcessor - function that will process entries that were added since the last time
        Returns:
        result of entryProcessor
        Throws:
        org.springframework.dao.DataAccessException - if entries could not be fetched or the journal state could not be saved
      • getMostRecentId

        public Optional<JournalEntry> getMostRecentId​(@NonNull JournalIdentifier journalIdentifier)
                                               throws org.springframework.dao.DataAccessException
        Description copied from interface: JournalManager
        Gets the most recent entry in the journal for the given journal identifier
        Specified by:
        getMostRecentId in interface JournalManager
        Parameters:
        journalIdentifier - journal to obtain the most recent entry
        Returns:
        the most recent entry or Optional.empty() if none found
        Throws:
        org.springframework.dao.DataAccessException
      • setMostRecentId

        public void setMostRecentId​(@NonNull JournalIdentifier journalIdentifier,
                                    long id)
                             throws org.springframework.dao.DataAccessException
        Description copied from interface: JournalManager
        Stores the most recent journal entry id in the journal store
        Specified by:
        setMostRecentId in interface JournalManager
        Parameters:
        journalIdentifier - identifier of the journal to store the most recent id
        id - value of the most recent id
        Throws:
        org.springframework.dao.DataAccessException - if entries could not be fetched or the journal state could not be saved
      • setMostRecentId

        public void setMostRecentId​(@NonNull JournalEntry journalEntry)
                             throws org.springframework.dao.DataAccessException
        Description copied from interface: JournalManager
        Stores the most recent journal entry id in the journal store
        Specified by:
        setMostRecentId in interface JournalManager
        Parameters:
        journalEntry - journal entry to store as the most recent
        Throws:
        org.springframework.dao.DataAccessException - if entries could not be fetched or the journal state could not be saved