@PublicApi
public interface JournalService
Typical way to use journal subsystem is to call enqueue(com.atlassian.confluence.api.model.journal.JournalEntry)
to queue new entries that should be actioned on each cluster node. Later on
queued entries can be processed by calling
processEntries(com.atlassian.confluence.api.model.journal.JournalIdentifier, int, com.google.common.base.Function)
on each cluster node. Subsequent calls to processEntries will be
passed only entries that were added since the last call on that cluster
node.
Modifier and Type | Method and Description |
---|---|
int |
countEntries(@NonNull JournalIdentifier journalId)
Counts the number of entries in a journal.
|
long |
enqueue(@NonNull JournalEntry entry)
Adds the given entry to a journal.
|
Iterable<JournalEntry> |
peek(@NonNull JournalIdentifier journalId,
int maxEntries)
Return a copy of journal entries that are waiting to be processed.
|
<V> V |
processEntries(@NonNull JournalIdentifier journalId,
int maxEntries,
com.google.common.base.Function<Iterable<JournalEntry>,EntryProcessorResult<V>> entryProcessor)
Deprecated.
since 7.0.1. Use
processNewEntries(JournalIdentifier, int, Function) |
default <V> V |
processNewEntries(@NonNull JournalIdentifier journalId,
int maxEntries,
@NonNull Function<Iterable<JournalEntry>,EntryProcessorResult<V>> entryProcessor)
Processes journal entries that were added since the last time this
method was called for this journal on this cluster node.
|
void |
reset(@NonNull JournalIdentifier journalId)
Resets the state of the journal so that all entries currently in the
journal will be skipped.
|
void |
waitForRecentEntriesToBecomeVisible()
Waits long enough to ensure that entries added before calling this
method will be available to subsequent call to
processNewEntries(JournalIdentifier, int, Function) . |
long enqueue(@NonNull JournalEntry entry) throws ServiceException
New journal is automatically created if a journal with the given name does not exists.
entry
- entry to persistServiceException
- if the entry could not be persisted@Deprecated <V> V processEntries(@NonNull JournalIdentifier journalId, int maxEntries, com.google.common.base.Function<Iterable<JournalEntry>,EntryProcessorResult<V>> entryProcessor) throws ServiceException
processNewEntries(JournalIdentifier, int, Function)
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.
journalId
- only entries with this journal id will be returnedmaxEntries
- maximum number of entries to processentryProcessor
- function that will process entries that were added
since the last timeServiceException
- if entries could not be fetched or the journal state could not be saveddefault <V> V processNewEntries(@NonNull JournalIdentifier journalId, int maxEntries, @NonNull Function<Iterable<JournalEntry>,EntryProcessorResult<V>> entryProcessor) throws ServiceException
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.
journalId
- only entries with this journal id will be returnedmaxEntries
- maximum number of entries to processentryProcessor
- function that will process entries that were added
since the last timeServiceException
- if entries could not be fetched or the journal state could not be savedvoid waitForRecentEntriesToBecomeVisible() throws InterruptedException
processNewEntries(JournalIdentifier, int, Function)
.InterruptedException
- if the thread got interruptedIterable<JournalEntry> peek(@NonNull JournalIdentifier journalId, int maxEntries) throws ServiceException
journalId
- only entries with this journal id will be returnedmaxEntries
- maximum number of entries to returnServiceException
- if entries could not be fetchedvoid reset(@NonNull JournalIdentifier journalId) throws ServiceException
journalId
- identifier of the journal to resetServiceException
- if the reset failsint countEntries(@NonNull JournalIdentifier journalId) throws ServiceException
journalId
- identifier of the journalServiceException
- if entries could not be countedCopyright © 2003–2019 Atlassian. All rights reserved.