public interface NotificationRepository
notifications.
A repository is responsible for handling CRUD and data parsing operations around these objects, in whatever scheme necessary.
Production implementations are expected to be thread safe, even across a network.
| Modifier and Type | Method and Description |
|---|---|
void |
ensureTransactionActive(Notification notification)
Throws a descriptive exception if the provided
notification is not in an active
transaction, or if the current state of its transaction is unknown. |
void |
markNotificationsProcessedOrFailed(Collection<? extends Notification> notification,
Collection<FailedNotification> failures) |
List<? extends Notification> |
retrieveOldestNotificationsUpTo(int maxNotifications)
Retrieves the oldest
maxNotifications notifications, oldest
first. |
List<? extends Notification> retrieveOldestNotificationsUpTo(int maxNotifications) throws Exception
maxNotifications notifications, oldest
first.
Once retrieved, a notification should not be retrieved again, atomically. That is, many threads looking up notifications at the same time should all et a unique non-overlapping sample of the oldest notifications. Subsequent calls should always return a unique set.
Retrieved notifications begin a transaction with those notifications. Calling
markNotificationsProcessedOrFailed(Collection, Collection) ends this transaction
on the provided notifications. This transaction may end for other reasons, such as a
distributed lock failure or timeout, which would cause subsequent calls to retrieve these
same notifications again. To determine if a transaction is still active around this, before
notifications' document events are added, ensureTransactionActive(Notification)
should be called in order to determine if that notification's transaction is lost or has
otherwise ended prematurely.
Exceptionvoid ensureTransactionActive(Notification notification) throws Exception
notification is not in an active
transaction, or if the current state of its transaction is unknown.
Transactions are started when an event is retrieved from
retrieveOldestNotificationsUpTo(int).
Transactions can end before published or failure confirmation for a variety of reasons, such as network failure or timeout, depending on the implementation.
Exception - if the event does not have an active transaction, and therefore is
available for processing from retrieveOldestNotificationsUpTo(int).void markNotificationsProcessedOrFailed(Collection<? extends Notification> notification, Collection<FailedNotification> failures) throws Exception
ExceptionCopyright © 2016. All rights reserved.