AMPS C/C++ Client Class Reference
AMPS C/C++ Client Version 5.3.4.3
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...
 
StoreImplget ()
 Used to get a pointer to the implementation. More...
 

Detailed Description

Handle class for StoreImpl classes that track publish messages.

Member Function Documentation

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
PublishStoreGapExceptionIf index_ < getLastPersisted() which could leave a gap on the server of missing messages from this Client.
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
DisconnectedExceptionThe Client is no longer connected to a server.
ConnectionExceptionAn error occurred while sending the message.
TimedOutExceptionThe publish command was not acked in the allowed time.
StoreImpl* AMPS::Store::get ( )
inline

Used to get a pointer to the implementation.

Returns
The StoreImpl* for this store's implementation.
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.
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.
amps_uint64_t AMPS::Store::getLowestUnpersisted ( )
inline

Get the oldest unpersisted message sequence in the store.

Returns
The sequence of the oldest message.
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.
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.
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.
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.
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.
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.
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: