AMPS C/C++ Client Class Reference AMPS C/C++ Client Version 5.3.5.6

Public Member Functions | List of all members
AMPS::Store Class Reference

Handle class for StoreImpl classes that track publish messages. More...

`#include <ampsplusplus.hpp>`

## Public Member Functions
amps_uint64_t | store (const Message &message_)
| Called by Client to store a message being published. More...
void | discardUpTo (amps_uint64_t index_)
| Called by Client to indicate that all messages up to and including. More...
void | replay (StoreReplayer &replayer_)
| Called by Client to get all stored and non-discarded messages replayed by the store onto the StoreReplayer. More...
bool | replaySingle (StoreReplayer &replayer_, amps_uint64_t index_)
| Called by Client to get a single message replayed by the store onto the StoreReplayer. More...
size_t | unpersistedCount () const
| Method to return how many messages are in the store that have not been discarded, indicating that they are not yet persisted by the AMPS server. More...
bool | isValid () const
| Method to return if there is an underlying implementation for the Store. More...
void | flush (long timeout_=0)
| Method to wait for the Store to discard everything that has been stored up to the point in time when flush is called. More...
amps_uint64_t | getLowestUnpersisted ()
| Get the oldest unpersisted message sequence in the store. More...
amps_uint64_t | getLastPersisted ()
| Get the last persisted message sequence in the store. More...
void | setResizeHandler (PublishStoreResizeHandler handler_, void *userData_)
| Set a handler to be called if the Store needs to resize in order to keep storing messages. More...
void | setErrorOnPublishGap (bool errorOnPublishGap_)
| Called to enable or disable throwing PublishStoreGapException. More...
bool | getErrorOnPublishGap () const
| Called to check if the Store will throw PublishStoreGapException. More...
StoreImpl * | get ()
| Used to get a pointer to the implementation. More...

## Detailed Description

Handle class for StoreImpl classes that track publish messages.

## Member Function Documentation

## ◆ discardUpTo()

void AMPS::Store::discardUpTo | ( | amps_uint64_t | index_ | ) |
| inline

Called by Client to indicate that all messages up to and including.

Parameters

  index_ | have been successfully published to the server and are no longer required to be in the store.

Exceptions

  PublishStoreGapException | If index_ < getLastPersisted() which could leave a gap on the server of missing messages from this Client.

## ◆ flush()

void AMPS::Store::flush | ( | long | timeout_ = `0` | ) |
| inline

Method to wait for the Store to discard everything that has been stored up to the point in time when flush is called.

It will get the current max and wait up to timeout for that message to be discarded

Parameters

  timeout_ | The number of milliseconds to wait for the messages to be acknowledged by AMPS and discarded by the Store. 0 indicates no timeout.

Exceptions

  DisconnectedException | The Client is no longer connected to a server.
  ConnectionException | An error occurred while sending the message.
  TimedOutException | The publish command was not acked in the allowed time.

## ◆ get()

StoreImpl* AMPS::Store::get | ( |  | ) |
| inline

Used to get a pointer to the implementation.

Returns
  The StoreImpl* for this store's implementation.

## ◆ getErrorOnPublishGap()

bool AMPS::Store::getErrorOnPublishGap | ( |  | ) | const
| inline

Called to check if the Store will throw PublishStoreGapException.

Returns
  If true, PublishStoreGapException can be thrown by the store if the client logs onto a server that appears to be missing messages no longer held in the store.

## ◆ getLastPersisted()

amps_uint64_t AMPS::Store::getLastPersisted | ( | void |  | ) |
| inline

Get the last persisted message sequence in the store.

Returns
  The sequence of the last persisted message.

## ◆ getLowestUnpersisted()

amps_uint64_t AMPS::Store::getLowestUnpersisted | ( |  | ) |
| inline

Get the oldest unpersisted message sequence in the store.

Returns
  The sequence of the oldest message.

## ◆ isValid()

bool AMPS::Store::isValid | ( |  | ) | const
| inline

Method to return if there is an underlying implementation for the Store.

Returns
  Returns true if there is an implementation or false if an empty handle.

## ◆ replay()

void AMPS::Store::replay | ( | StoreReplayer & | replayer_ | ) |
| inline

Called by Client to get all stored and non-discarded messages replayed by the store onto the StoreReplayer.

Parameters

  replayer_ | The StoreReplayer to be used to replay the messages.

## ◆ replaySingle()

bool AMPS::Store::replaySingle | ( | StoreReplayer & | replayer_,
|  | amps_uint64_t | index_
| ) |  |
| inline

Called by Client to get a single message replayed by the store onto the StoreReplayer.

Parameters

  replayer_ | The StoreReplayer to be used to replay the messages.
  index_ | The index of the message to replay.

Returns
  Returns true for success, false for failure such as an invalid index.

## ◆ setErrorOnPublishGap()

void AMPS::Store::setErrorOnPublishGap | ( | bool | errorOnPublishGap_ | ) |
| inline

Called to enable or disable throwing PublishStoreGapException.

Parameters

  errorOnPublishGap_ | If true, PublishStoreGapException can be thrown by the store if the client logs onto a server that appears to be missing messages no longer held in the store.

## ◆ setResizeHandler()

void AMPS::Store::setResizeHandler | ( | PublishStoreResizeHandler | handler_,
|  | void * | userData_
| ) |  |
| inline

Set a handler to be called if the Store needs to resize in order to keep storing messages.

Resize could be caused by not being connected to the server, publishing messages faster than the network or AMPS can keep up, not properly discarding messages when receiving persisted acks, or AMPS being unable to complete persistence such as when its connection to a sync replication destination is unavailable.

Parameters

  handler_ | The handler to be called when a resize event is required.
  userData_ | The data to pass to the handler each time it is called.

## ◆ store()

amps_uint64_t AMPS::Store::store | ( | const Message & | message_ | ) |
| inline

Called by Client to store a message being published.

Parameters

  message_ | The message to store.

## ◆ unpersistedCount()

size_t AMPS::Store::unpersistedCount | ( |  | ) | const
| inline

Method to return how many messages are in the store that have not been discarded, indicating that they are not yet persisted by the AMPS server.

Returns
  The number of messages not yet persisted by the AMPS server.

The documentation for this class was generated from the following file:

- include/amps/ampsplusplus.hpp