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, bookmarkSeqNo: number): 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 subscription 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 subscription resumes.

    Parameters

    • subId: string

      The subscription id.

    • bookmarkSeqNo: number

      The bookmark sequence in the store.

    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

  • This method is called internally by the Client to log a bookmark to the persistent log.

    Parameters

    • message: Message

      The message to bookmark.

    Returns number

    The corresponding bookmark sequence in the store.

mostRecent

  • 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.

    • Default value useList: boolean = true

    Returns BookmarkField

    The most recent bookmark.

oldestBookmarkSeq

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

    Parameters

    • subId: string

      The identifier of the subscription.

    Returns number

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

persisted

  • 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: BookmarkField

      A bookmark field object.

    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