Options
All
  • Public
  • Public/Protected
  • All
Menu

Class MemoryBookmarkStore

Bookmark store is used by the Client to provide resumable subscriptions and client-side duplicate message handling using in-memory storage.

// create the bookmark store
var bookmarkStore = new amps.MemoryBookmarkStore();

// create the client instance and assign the bookmark store to it
var client = new amps.Client('my-client');
client.bookmarkStore(bookmarkStore);

// ... access the bookmark store later
client.bookmarkStore().purge();

Hierarchy

  • MemoryBookmarkStore

Implements

Index

Methods

discard

  • discard(message: Message): void
  • discard(subId: string, bookmark: string): void
  • This method is called when you want to mark the message object as discarded, indicating that the application has completed processing the message. Marking a message as discarded means that the message will not be replayed when the subcription resumes.

    Parameters

    • message: Message

      The message object.

    Returns void


  • This method is called when you want to mark the message specified by the subscription ID and the bookmark sequence number as discarded, indicating that the application has completed processing the message. Marking a message as discarded means that the message will not be replayed when the subcription resumes.

    Parameters

    • subId: string

      The subscription id.

    • bookmark: string

      The bookmark field value in a message.

    Returns void

isDiscarded

  • isDiscarded(message: Message): boolean
  • This method is called for each arriving message to determine if the application has already processed and discarded this message. Returns 'true' if the bookmark is in the log and marked as discarded and should therefore not be reprocessed. Otherwise, returns 'false'. Generally, isDiscarded is called by the Client however, if needed it can be called by the application as well.

    Parameters

    • message: Message

      The message to check.

    Returns boolean

    true if the bookmark is in the log and marked as discarded and should therefore not be reprocessed. Otherwise, returns false.

log

  • log(message: Message): BigInteger
  • This method is called internally by the Client to log a bookmark to the persistent log.

    Parameters

    • message: Message

      The message to bookmark.

    Returns BigInteger

    The corresponding bookmark sequence number for this bookmark.

mostRecent

  • mostRecent(subId: string): string
  • This method is called when you want to return the most recent bookmark from the log that ought to be used for (re-)subscriptions.

    Parameters

    • subId: string

      The subscription id.

    Returns string

    The most recent bookmark.

noPersistedAcks

  • noPersistedAcks(subId: string): void
  • This method notifies the bookmark store that the subscription won't receive persisted acks.

    Parameters

    • subId: string

      The subscription id.

    Returns void

oldestBookmarkSeq

  • oldestBookmarkSeq(subId: string): BigInteger
  • This method is called when you want to retrieve the sequence number of the oldest bookmark in the store.

    Parameters

    • subId: string

      The identifier of the subscription.

    Returns BigInteger

    The sequence number of the oldest bookmark in the store. 0 if not found/doesn't exist

persisted

  • persisted(subId: string, bookmark: string): void
  • This method is called internally by the Client to mark a message as safely persisted by AMPS to all of its sync replication destinations.

    Parameters

    • subId: string

      The identifier of the subscription.

    • bookmark: string

      A raw bookmark string.

    Returns void

purge

  • purge(subId?: string): void
  • This method is called when you want to purge the contents of this store. If the subId is not provided, removes any tracking history associated with publishers and received messages. Otherwise, removes history for that subId only.

    Parameters

    • Optional subId: string

      The identifier of the subscription to purge.

    Returns void