public class RingBookmarkStore extends java.lang.Object implements BookmarkStore
| Modifier and Type | Class and Description |
|---|---|
protected static class |
RingBookmarkStore.Subscription
The Subscription object is used to represent internal bookmark state
for the messages received and discarded on a specific subscription
within the bookmark store.
|
| Constructor and Description |
|---|
RingBookmarkStore(java.lang.String path)
Initializes a `RingBookmarkStore` object with the provided file path.
|
RingBookmarkStore(java.lang.String path,
int targetNumberOfSubscriptions)
Initializes a `RingBookmarkStore` object with a specified file path and a
target number of subscriptions.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
In order to unmap the memory used to store the state, this method closes the
mapped byte buffer.
|
void |
discard(Field subId,
long bookmarkSeqNo)
Marks the message specified by the Subscription ID and bookmark sequence
number as discarded, indicating that the application has completed processing
the message.
|
void |
discard(Message message)
Call this when you want to mark the provided message as discarded, indicating
that the application has completed processing the message.
|
protected RingBookmarkStore.Subscription |
find(Field subId)
Finds and returns the `Subscription` object associated with the specified
subscription ID (`subId`).
|
Field |
getMostRecent(Field subId)
Call this when you want to return to the most recent bookmark from the log
that should be used for (re-)subscriptions based on the provided subscription
ID.
|
Field |
getMostRecent(Field subId,
boolean useList)
Call this when you want to return to the most recent bookmark from the log
that should be used for (re-)subscriptions based on the provided subscription
ID.
|
long |
getOldestBookmarkSeq(Field subId)
Call this when you want to retrieve the sequence number for the oldest
bookmark in the store.
|
int |
getServerVersion()
Called internally by the Client to return the server version detected upon
logon.
|
boolean |
isDiscarded(Message message)
Called for each arriving message to determine if the application has already
processed and discarded the message.
|
long |
log(Message message)
This method is called internally by the AMPS Client to log a bookmark to
the persistent log.
|
void |
persisted(Field subId,
BookmarkField bookmark)
Called internally by the Client to mark the message as safely persisted by
AMPS to all of its sync replication destinations.
|
void |
persisted(Field subId,
long bookmark)
Deprecated.
use
persisted(Field, BookmarkField) instead. |
void |
purge()
Call this when you want to purge the contents of this store.
|
void |
purge(Field subId_)
Call this when you want to purge the contents of this store for a given
Subscription Id.
|
void |
setResizeHandler(BookmarkStoreResizeHandler handler)
Call this when you want to set a resize handler that is invoked when the
store needs to resize.
|
void |
setServerVersion(int version)
Called internally by the Client when connected to an AMPS server to indicate
what version the server is.
|
public RingBookmarkStore(java.lang.String path)
throws AMPSException
path - The path to the file.AMPSException - Thrown when an operation on the store fails. The
exception will contain details of the failure.public RingBookmarkStore(java.lang.String path,
int targetNumberOfSubscriptions)
throws AMPSException
path - The path to the file.targetNumberOfSubscriptions - The target number of subscriptions.AMPSException - Thrown when an operation on the store fails.
The exception will contain details of the failure.public long log(Message message) throws AMPSException
log in interface BookmarkStoremessage - The AMPS Message.AMPSException - Thrown when an operation on the store fails. The
exception will contain details of the failure.public void discard(Field subId, long bookmarkSeqNo) throws AMPSException
discard in interface BookmarkStoresubId - The subscription ID of the message.bookmarkSeqNo - The bookmark sequence number.AMPSException - Thrown when an operation on the store fails. The
exception will contain details of the failure.public void discard(Message message) throws AMPSException
discard in interface BookmarkStoremessage - Message to be marked as discarded.AMPSException - Thrown when an operation on the store fails. The
exception will contain details of the failure.public Field getMostRecent(Field subId) throws AMPSException
getMostRecent in interface BookmarkStoresubId - Subscription IdAMPSException - Thrown when an operation on the store fails. The
exception will contain details of the failure.public Field getMostRecent(Field subId, boolean useList) throws AMPSException
getMostRecent in interface BookmarkStoresubId - Subscription IduseList - Ignored by this type of store.AMPSException - Thrown when an operation on the store fails. The
exception will contain details of the failure.public boolean isDiscarded(Message message) throws AMPSException
isDiscarded in interface BookmarkStoremessage - Message used to determine if the application has alreadyAMPSException - Thrown when an operation on the store fails. The
exception will contain details of the failure.protected RingBookmarkStore.Subscription find(Field subId) throws AMPSException
subId - The subscription ID for which to find or create a Subscription.AMPSException - Thrown when there is an error in the bookmark store or
when there is insufficient space to create a new
Subscription.public void persisted(Field subId, BookmarkField bookmark) throws AMPSException
persisted in interface BookmarkStoresubId - The subscription ID for the message.bookmark - The bookmark containing the message.AMPSException - Not thrown by this implementation.@Deprecated public void persisted(Field subId, long bookmark) throws AMPSException
persisted(Field, BookmarkField) instead.persisted in interface BookmarkStoresubId - The subscription ID for the message.bookmark - The bookmark number.AMPSException - Not thrown by this implementation.public long getOldestBookmarkSeq(Field subId) throws AMPSException
getOldestBookmarkSeq in interface BookmarkStoresubId - The subscription ID for the oldest bookmark in the store.AMPSException - Thrown when an operation on the store fails. The
exception will contain details of the failure.public void setResizeHandler(BookmarkStoreResizeHandler handler)
setResizeHandler in interface BookmarkStorehandler - The handler to invoke for the resize.public void purge()
throws AMPSException
purge in interface BookmarkStoreAMPSException - Thrown when an operation on the store fails. The
exception will contain details of the failure.public void purge(Field subId_) throws AMPSException
purge in interface BookmarkStoresubId_ - The identifier of the subscription to purge.AMPSException - Thrown when an operation on the store fails. The
exception will contain details of the failure.public void setServerVersion(int version)
setServerVersion in interface BookmarkStoreversion - Version numberpublic int getServerVersion()
public void close()
throws java.lang.Exception
close in interface java.lang.AutoCloseablejava.lang.Exception - Thrown when an operation on the store fails. The exception
will contain details of the failure.