Interface JournalService

    • Method Detail

      • enqueue

        long enqueue​(@NonNull JournalEntry entry)
              throws ServiceException
        Adds the given entry to a journal.

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

        Parameters:
        entry - entry to persist
        Returns:
        id generated for the entry
        Throws:
        ServiceException - if the entry could not be persisted
      • processEntries

        @Deprecated
        <V> V processEntries​(@NonNull JournalIdentifier journalId,
                             int maxEntries,
                             @NonNull com.google.common.base.Function<Iterable<JournalEntry>,​EntryProcessorResult<V>> entryProcessor)
                      throws ServiceException
        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 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.

        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:
        ServiceException - if entries could not be fetched or the journal state could not be saved
      • processNewEntries

        default <V> V processNewEntries​(@NonNull JournalIdentifier journalId,
                                        int maxEntries,
                                        @NonNull Function<Iterable<JournalEntry>,​EntryProcessorResult<V>> entryProcessor)
                                 throws ServiceException
        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 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.

        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:
        ServiceException - if entries could not be fetched or the journal state could not be saved
        Since:
        7.0.1
      • peek

        Iterable<JournalEntry> peek​(@NonNull JournalIdentifier journalId,
                                    int maxEntries)
                             throws ServiceException
        Return a copy of journal entries that are waiting to be processed.
        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
        Throws:
        ServiceException - if entries could not be fetched
      • reset

        void reset​(@NonNull JournalIdentifier journalId)
            throws ServiceException
        Resets the state of the journal so that all entries currently in the journal will be skipped.
        Parameters:
        journalId - identifier of the journal to reset
        Throws:
        ServiceException - if the reset fails
      • countEntries

        int countEntries​(@NonNull JournalIdentifier journalId)
                  throws ServiceException
        Counts the number of entries in a journal.
        Parameters:
        journalId - identifier of the journal
        Throws:
        ServiceException - if entries could not be counted