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

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

A highly-available Client that automatically reconnects and re-subscribes to AMPS instances upon disconnect. More...

`#include <HAClient.hpp>`

Inheritance diagram for AMPS::HAClient:

## Public Member Functions
| HAClient ()
| Create an HAClient with no name The name for the client must be set using setName before it can be used.
| HAClient (const std::string &name_)
| Create an HAClient with the given name. More...
| HAClient (HAClientImpl *body_)
| Create an HAClient wrapping the given implementation, used internally. More...
| HAClient (const HAClient &rhs)
| Copy constructor, makes a new reference to the same body. More...
HAClient & | operator= (const HAClient &rhs)
| Assignment operator, the body will be shared after this. More...
void | setTimeout (int timeout_)
| Set the timeout used when logging into AMPS. More...
int | getTimeout () const
| Get the current timeout used when attempting to log into AMPS. More...
void | setReconnectDelay (int reconnectDelay_)
| Set the delay between reconnect attempts in milliseconds. More...
int | getReconnectDelay () const
| The current delay in milliseconds between reconnect attempts. More...
void | setReconnectDelayStrategy (const ReconnectDelayStrategy &strategy_)
| Set the ReconnectDelayStrategy used to control delay behavior when connecting and reconnecting to servers. More...
ReconnectDelayStrategy | getReconnectDelayStrategy (void) const
| Get the ReconnectDelayStrategy used to control delay behavior when connecting and reconnecting to servers. More...
std::string | getLogonOptions (void) const
| Get the options passed to the server during logon. More...
void | setLogonOptions (const char *logonOptions_)
| Set the options passed to the server during logon.
void | setLogonOptions (const std::string &logonOptions_)
| Set the options passed to the server during logon.
ServerChooser | getServerChooser () const
| Return the ServerChooser currently used by the HAClient. More...
void | setServerChooser (const ServerChooser &serverChooser_)
| Set the ServerChooser used to determine the URI used when trying to connect and logon to AMPS. More...
void | connectAndLogon ()
| Connect and logon to AMPS using the server(s) from the ServerChooser set on this HAClient and the Authenticator set on this HAClient to to provide logon information. More...
bool | disconnected () const
| Return whether or not the client is disconnected. More...
ConnectionInfo | getConnectionInfo () const
| Get the connection information for the current connection. More...
ConnectionInfo | gatherConnectionInfo () const
void | setDisconnectHandler (const DisconnectHandler &)
Public Member Functions inherited from AMPS::Client
| Client (const std::string &clientName="")
| Constructs a new client with a given client name. More...
void | setName (const std::string &name)
| Sets the name of this client, assuming no name was provided previously. More...
const std::string & | getName () const
| Returns the name of this client passed in the constructor. More...
const std::string & | getNameHash () const
| Returns the name hash string of this client as generated by the server and returned when the client logged on. More...
const amps_uint64_t | getNameHashValue () const
| Returns the numeric name hash of this client as generated by the server and returned when the client logged on. More...
const std::string & | getConnectionName () const
| Returns the connection name string of this client as generated by the server and returned when the client logged on. More...
void | setLogonCorrelationData (const std::string &logonCorrelationData_)
| Sets the logon correlation data for the client. More...
const std::string & | getLogonCorrelationData () const
| Returns the currently set logon correlation data for the client. More...
void | addHttpPreflightHeader (const std::string &header_)
| Adds a given HTTP header line to the end of the headers that will be sent for the HTTP GET Upgrade request. More...
void | addHttpPreflightHeader (const std::string &key_, const std::string &value_)
| Adds a given key/value pair as an HTTP header line as "key: value" to the end of the headers that will be sent for the HTTP GET Upgrade request. More...
void | clearHttpPreflightHeaders ()
| Clears all previously set HTTP header lines.
template<class T >
void | setHttpPreflightHeaders (const T &headers_)
| Sets the given HTTP header lines to be sent for the HTTP GET Upgrade request. More...
size_t | getServerVersion () const
| Returns the server version retrieved during logon. More...
VersionInfo | getServerVersionInfo () const
| Returns the server version retrieved during logon. More...
const std::string & | getURI () const
| Returns the last URI this client is connected to. More...
void | connect (const std::string &uri)
| Connect to an AMPS server. More...
void | disconnect ()
| Disconnect from an AMPS server. More...
void | send (const Message &message)
| Sends a Message to the connected AMPS server, performing only minimal validation and bypassing client services such as the publish store. More...
void | addMessageHandler (const Field &commandId_, const AMPS::MessageHandler &messageHandler_, unsigned requestedAcks_, bool isSubscribe_)
| Adds a MessageHandler to be invoked for Messages with the given CommandId as their command id, sub id, or query id. More...
void | addMessageHandler (const Field &commandId_, const AMPS::MessageHandler &messageHandler_, unsigned requestedAcks_, Message::Command::Type commandType_)
| Adds a MessageHandler to be invoked for Messages with the given CommandId as their command id, sub id, or query id. More...
bool | removeMessageHandler (const Field &commandId_)
| Removes a MessageHandler for a given ComandId from self. More...
std::string | send (const MessageHandler &messageHandler_, Message &message_, int timeout_=0, AMPS_ATOMIC_BASE_TYPE subscribeGeneration_=0)
| Sends a Message to the connected AMPS server, performing only minimal validation and bypassing client services such as the publish store. More...
DisconnectHandler | getDisconnectHandler (void) const
void | setBookmarkStore (const BookmarkStore &bookmarkStore_)
| Set the bookmark store to be used by the client. More...
BookmarkStore | getBookmarkStore ()
| Get the bookmark store being used by the client. More...
SubscriptionManager * | getSubscriptionManager ()
| Get the subscription manager being used by the client. More...
void | setSubscriptionManager (SubscriptionManager *subscriptionManager_)
| Set the subscription manager to be used by the client. More...
void | setPublishStore (const Store &publishStore_)
| Set the publish store to be used by the client. More...
Store | getPublishStore ()
| Get the publish store used by the client. More...
void | setDuplicateMessageHandler (const MessageHandler &duplicateMessageHandler_)
| Sets a callback function that is invoked when a duplicate message is detected. More...
MessageHandler | getDuplicateMessageHandler (void)
| Returns the callback function that is invoked when a duplicate message is detected. More...
void | setFailedWriteHandler (FailedWriteHandler *handler_)
| Set the handler that is invoked to report when a publish fails, for example if the publisher is not entitled, if AMPS attempts to parse the message and the parse fails, and so on. More...
FailedWriteHandler * | getFailedWriteHandler ()
| Get the handler that is invoked to report on failed writes. More...
amps_uint64_t | publish (const std::string &topic_, const std::string &data_)
| Publish a message to an AMPS topic, returning the sequence number assigned by the publish store if one is present on the client. More...
amps_uint64_t | publish (const char *topic_, size_t topicLength_, const char *data_, size_t dataLength_)
| Publish a message to an AMPS topic, returning the sequence number assigned by the publish store if one is present on the client. More...
amps_uint64_t | publish (const std::string &topic_, const std::string &data_, unsigned long expiration_)
| Publish a message to an AMPS topic, returning the sequence number assigned by the publish store (if a publish store is present on the client). More...
amps_uint64_t | publish (const char *topic_, size_t topicLength_, const char *data_, size_t dataLength_, unsigned long expiration_)
| Publish a message to an AMPS topic, returning the sequence number assigned by the publish store if one is present on the client. More...
amps_uint64_t | publish (const std::string &topic_, const std::string &data_, const std::string &correlationId_)
| Publish a message to an AMPS topic, returning the sequence number assigned by the publish store if one is present on the client. More...
amps_uint64_t | publish (const char *topic_, size_t topicLength_, const char *data_, size_t dataLength_, const char *correlationId_, size_t correlationIdLength_)
| Publish a message to an AMPS topic, returning the sequence number assigned by the publish store if one is present on the client. More...
amps_uint64_t | publish (const std::string &topic_, const std::string &data_, const std::string &correlationId_, unsigned long expiration_)
| Publish a message to an AMPS topic, returning the sequence number assigned by the publish store (if a publish store is present on the client). More...
amps_uint64_t | publish (const char *topic_, size_t topicLength_, const char *data_, size_t dataLength_, const char *correlationId_, size_t correlationIdLength_, unsigned long expiration_)
| Publish a message to an AMPS topic, returning the sequence number assigned by the publish store if one is present on the client. More...
amps_uint64_t | publish (const std::string &topic_, const std::string &data_, const std::string &correlationId_, const std::string &sowKey_)
| Publish a message to an AMPS topic, returning the sequence number assigned by the publish store if one is present on the client. More...
amps_uint64_t | publish (const char *topic_, size_t topicLength_, const char *data_, size_t dataLength_, const char *correlationId_, size_t correlationIdLength_, const char *sowKey_, size_t sowKeyLength_)
| Publish a message to an AMPS topic, returning the sequence number assigned by the publish store if one is present on the client. More...
amps_uint64_t | publish (const std::string &topic_, const std::string &data_, const std::string &correlationId_, const std::string &sowKey_, unsigned long expiration_)
| Publish a message to an AMPS topic, returning the sequence number assigned by the publish store (if a publish store is present on the client). More...
amps_uint64_t | publish (const char *topic_, size_t topicLength_, const char *data_, size_t dataLength_, const char *correlationId_, size_t correlationIdLength_, const char *sowKey_, size_t sowKeyLength_, unsigned long expiration_)
| Publish a message to an AMPS topic, returning the sequence number assigned by the publish store if one is present on the client. More...
amps_uint64_t | publish (Message &message_)
| Publish a message to an AMPS topic, returning the sequence number assigned by the publish store if one is present on the client. More...
amps_uint64_t | publishKeyed (const std::string &topic_, const std::string &data_, const std::string &sowKey_)
| Publish a message to an AMPS topic, returning the sequence number assigned by the publish store if one is present on the client. More...
amps_uint64_t | publishKeyed (const char *topic_, size_t topicLength_, const char *data_, size_t dataLength_, const char *sowKey_, size_t sowKeyLength_)
| Publish a message to an AMPS topic, returning the sequence number assigned by the publish store if one is present on the client. More...
amps_uint64_t | publishKeyed (const std::string &topic_, const std::string &data_, const std::string &sowKey_, unsigned long expiration_)
| Publish a message to an AMPS topic, returning the sequence number assigned by the publish store (if a publish store is present on the client). More...
amps_uint64_t | publishKeyed (const char *topic_, size_t topicLength_, const char *data_, size_t dataLength_, const char *sowKey_, size_t sowKeyLength_, unsigned long expiration_)
| Publish a message to an AMPS topic, returning the sequence number assigned by the publish store if one is present on the client. More...
void | publishFlush (long timeout_=0, unsigned ackType_=Message::AckType::Processed)
| Ensure that AMPS messages are sent and have been processed by the AMPS server. More...
amps_uint64_t | deltaPublish (const std::string &topic_, const std::string &data_)
| Publish the changed fields of a message to an AMPS topic. More...
amps_uint64_t | deltaPublish (const char *topic_, size_t topicLength_, const char *data_, size_t dataLength_)
| Publish the changed fields of a message to an AMPS topic. More...
amps_uint64_t | deltaPublish (const std::string &topic_, const std::string &data_, unsigned long expiration_)
| Publish the changed fields of a message to an AMPS topic. More...
amps_uint64_t | deltaPublish (const char *topic_, size_t topicLength_, const char *data_, size_t dataLength_, unsigned long expiration_)
| Publish the changed fields of a message to an AMPS topic. More...
std::string | logon (int timeout_=0, Authenticator &authenticator_=DefaultAuthenticator::instance(), const char *options_=NULL)
| Logon to the server, providing the client name, credentials (if available), and client information (such as client version and connection message type). More...
std::string | logon (const char *options_, int timeout_=0)
| Logon to the server, providing the client name, credentials (if available) client information (such as client version and connection message type), and the specified options. More...
std::string | logon (const std::string &options_, int timeout_=0)
| Logon to the server, providing the client name, credentials (if available) client information (such as client version and connection message type), and the specified options. More...
std::string | subscribe (const MessageHandler &messageHandler_, const std::string &topic_, long timeout_=0, const std::string &filter_="", const std::string &options_="", const std::string &subId_="")
| Subscribe to a topic. More...
MessageStream | subscribe (const std::string &topic_, long timeout_=0, const std::string &filter_="", const std::string &options_="", const std::string &subId_="")
| Subscribe to a topic. More...
MessageStream | subscribe (const char *topic_, long timeout_=0, const std::string &filter_="", const std::string &options_="", const std::string &subId_="")
| Subscribe to a topic. More...
std::string | deltaSubscribe (const MessageHandler &messageHandler_, const std::string &topic_, long timeout_, const std::string &filter_="", const std::string &options_="", const std::string &subId_="")
| Delta Subscribe to a topic. More...
MessageStream | deltaSubscribe (const std::string &topic_, long timeout_, const std::string &filter_="", const std::string &options_="", const std::string &subId_="")
| Delta Subscribe to a topic. More...
MessageStream | deltaSubscribe (const char *topic_, long timeout_, const std::string &filter_="", const std::string &options_="", const std::string &subId_="")
| Delta Subscribe to a topic. More...
std::string | bookmarkSubscribe (const MessageHandler &messageHandler_, const std::string &topic_, long timeout_, const std::string &bookmark_, const std::string &filter_="", const std::string &options_="", const std::string &subId_="")
| Subscribe to a topic using a bookmark. More...
MessageStream | bookmarkSubscribe (const std::string &topic_, long timeout_, const std::string &bookmark_, const std::string &filter_="", const std::string &options_="", const std::string &subId_="")
| Subscribe to a topic using a bookmark. More...
MessageStream | bookmarkSubscribe (const char *topic_, long timeout_, const std::string &bookmark_, const std::string &filter_="", const std::string &options_="", const std::string &subId_="")
| Subscribe to a topic using a bookmark. More...
void | unsubscribe (const std::string &commandId)
| Unsubscribe from a topic. More...
void | unsubscribe ()
| Unsubscribe from all topics. More...
std::string | sow (const MessageHandler &messageHandler_, const std::string &topic_, const std::string &filter_="", const std::string &orderBy_="", const std::string &bookmark_="", int batchSize_=DEFAULT_BATCH_SIZE, int topN_=DEFAULT_TOP_N, const std::string &options_="", long timeout_=DEFAULT_COMMAND_TIMEOUT)
| Query a State-of-the-World topic. More...
MessageStream | sow (const std::string &topic_, const std::string &filter_="", const std::string &orderBy_="", const std::string &bookmark_="", int batchSize_=DEFAULT_BATCH_SIZE, int topN_=DEFAULT_TOP_N, const std::string &options_="", long timeout_=DEFAULT_COMMAND_TIMEOUT)
| Query the SOW cache of a topic. More...
MessageStream | sow (const char *topic_, const std::string &filter_="", const std::string &orderBy_="", const std::string &bookmark_="", int batchSize_=DEFAULT_BATCH_SIZE, int topN_=DEFAULT_TOP_N, const std::string &options_="", long timeout_=DEFAULT_COMMAND_TIMEOUT)
| Query the SOW cache of a topic. More...
std::string | sow (const MessageHandler &messageHandler_, const std::string &topic_, long timeout_, const std::string &filter_="", int batchSize_=DEFAULT_BATCH_SIZE, int topN_=DEFAULT_TOP_N)
| Query the SOW cache of a topic. More...
std::string | sowAndSubscribe (const MessageHandler &messageHandler_, const std::string &topic_, long timeout_, const std::string &filter_="", int batchSize_=DEFAULT_BATCH_SIZE, bool oofEnabled_=false, int topN_=DEFAULT_TOP_N)
| Query the SOW cache of a topic and initiates a new subscription on it. More...
MessageStream | sowAndSubscribe (const std::string &topic_, long timeout_, const std::string &filter_="", int batchSize_=DEFAULT_BATCH_SIZE, bool oofEnabled_=false, int topN_=DEFAULT_TOP_N)
| Query the SOW cache of a topic and initiates a new subscription on it. More...
MessageStream | sowAndSubscribe (const char *topic_, long timeout_, const std::string &filter_="", int batchSize_=DEFAULT_BATCH_SIZE, bool oofEnabled_=false, int topN_=DEFAULT_TOP_N)
| Query the SOW cache of a topic and initiates a new subscription on it. More...
std::string | sowAndSubscribe (const MessageHandler &messageHandler_, const std::string &topic_, const std::string &filter_="", const std::string &orderBy_="", const std::string &bookmark_="", int batchSize_=DEFAULT_BATCH_SIZE, int topN_=DEFAULT_TOP_N, const std::string &options_="", long timeout_=DEFAULT_COMMAND_TIMEOUT)
| Query the SOW cache of a topic and initiates a new subscription on it. More...
MessageStream | sowAndSubscribe (const std::string &topic_, const std::string &filter_="", const std::string &orderBy_="", const std::string &bookmark_="", int batchSize_=DEFAULT_BATCH_SIZE, int topN_=DEFAULT_TOP_N, const std::string &options_="", long timeout_=DEFAULT_COMMAND_TIMEOUT)
| Query the SOW cache of a topic and initiates a new subscription on it. More...
MessageStream | sowAndSubscribe (const char *topic_, const std::string &filter_="", const std::string &orderBy_="", const std::string &bookmark_="", int batchSize_=DEFAULT_BATCH_SIZE, int topN_=DEFAULT_TOP_N, const std::string &options_="", long timeout_=DEFAULT_COMMAND_TIMEOUT)
| Query the SOW cache of a topic and initiates a new subscription on it. More...
std::string | sowAndDeltaSubscribe (const MessageHandler &messageHandler_, const std::string &topic_, const std::string &filter_="", const std::string &orderBy_="", int batchSize_=DEFAULT_BATCH_SIZE, int topN_=DEFAULT_TOP_N, const std::string &options_="", long timeout_=DEFAULT_COMMAND_TIMEOUT)
| Query the SOW cache of a topic and initiates a new delta subscription on it. More...
MessageStream | sowAndDeltaSubscribe (const std::string &topic_, const std::string &filter_="", const std::string &orderBy_="", int batchSize_=DEFAULT_BATCH_SIZE, int topN_=DEFAULT_TOP_N, const std::string &options_="", long timeout_=DEFAULT_COMMAND_TIMEOUT)
| Query the SOW cache of a topic and initiates a new delta subscription on it. More...
MessageStream | sowAndDeltaSubscribe (const char *topic_, const std::string &filter_="", const std::string &orderBy_="", int batchSize_=DEFAULT_BATCH_SIZE, int topN_=DEFAULT_TOP_N, const std::string &options_="", long timeout_=DEFAULT_COMMAND_TIMEOUT)
| Query the SOW cache of a topic and initiates a new delta subscription on it. More...
std::string | sowAndDeltaSubscribe (const MessageHandler &messageHandler_, const std::string &topic_, long timeout_, const std::string &filter_="", int batchSize_=DEFAULT_BATCH_SIZE, bool oofEnabled_=false, bool sendEmpties_=false, int topN_=DEFAULT_TOP_N)
| Query the SOW cache of a topic and initiates a new delta subscription on it. More...
MessageStream | sowAndDeltaSubscribe (const std::string &topic_, long timeout_, const std::string &filter_="", int batchSize_=DEFAULT_BATCH_SIZE, bool oofEnabled_=false, bool sendEmpties_=false, int topN_=DEFAULT_TOP_N)
| Query the SOW cache of a topic and initiates a new delta subscription on it. More...
MessageStream | sowAndDeltaSubscribe (const char *topic_, long timeout_, const std::string &filter_="", int batchSize_=DEFAULT_BATCH_SIZE, bool oofEnabled_=false, bool sendEmpties_=false, int topN_=DEFAULT_TOP_N)
| Query the SOW cache of a topic and initiates a new delta subscription on it. More...
std::string | sowDelete (const MessageHandler &messageHandler, const std::string &topic, const std::string &filter, long timeout)
| Deletes one or more messages from a topic's SOW cache. More...
Message | sowDelete (const std::string &topic_, const std::string &filter_, long timeout_=0)
| Deletes one or more messages from a topic's SOW cache. More...
void | startTimer ()
std::string | stopTimer (const MessageHandler &messageHandler)
std::string | sowDeleteByKeys (const MessageHandler &messageHandler_, const std::string &topic_, const std::string &keys_, long timeout_=0)
| Deletes messages that match SOW keys from a topic's SOW cache. More...
Message | sowDeleteByKeys (const std::string &topic_, const std::string &keys_, long timeout_=0)
| Deletes messages that match SOW keys from a topic's SOW cache. More...
std::string | sowDeleteByData (const MessageHandler &messageHandler_, const std::string &topic_, const std::string &data_, long timeout_=0)
| Deletes the message whose keys match the message data provided. More...
Message | sowDeleteByData (const std::string &topic_, const std::string &data_, long timeout_=0)
| Deletes the message whose keys match the message data provided. More...
amps_handle | getHandle ()
| Returns the underlying amps_handle for this client, to be used with amps_client_* functions from the C api. More...
void | setExceptionListener (const std::shared_ptr< const ExceptionListener > &pListener_)
| Sets the exception listener for exceptions that are not thrown back to the user (for example, exceptions that are thrown from a MessageHandler running on the client receive thread.) 60East strongly recommends setting this callback if an application uses asynchronous message processing (that is, provides message handler callbacks). More...
void | setExceptionListener (const ExceptionListener &listener_)
const ExceptionListener & | getExceptionListener (void) const
| Returns the exception listener set on this Client. More...
void | setHeartbeat (unsigned heartbeatTime_, unsigned readTimeout_)
| Requests heartbeating with the AMPS server. More...
void | setHeartbeat (unsigned heartbeatTime_)
| Requests heartbeating with the AMPS server. More...
void | setUnhandledMessageHandler (const AMPS::MessageHandler &messageHandler)
void | setLastChanceMessageHandler (const AMPS::MessageHandler &messageHandler)
| Sets the message handler called when no other handler matches. More...
void | setGlobalCommandTypeMessageHandler (const std::string &command_, const MessageHandler &handler_)
| Sets a handler for all messages of a particular type, or for messages that would be delivered to a particular special handler: currently supported types are "heartbeat", "ack", "duplicate", and "lastchance". More...
void | setGlobalCommandTypeMessageHandler (const Message::Command::Type command_, const MessageHandler &handler_)
| Sets a handler for all messages of a particular type: currently supported types are heartbeat messages and ack messages. More...
void | addConnectionStateListener (ConnectionStateListener *listener)
| Adds a ConnectionStateListener to self's set of listeners. More...
void | removeConnectionStateListener (ConnectionStateListener *listener)
| Attempts to remove listener from self's set of ConnectionStateListeners. More...
void | clearConnectionStateListeners ()
| Clear all listeners from self's set of ConnectionStateListeners.
std::string | executeAsync (Command &command_, MessageHandler handler_)
| Execute the provided command and, once AMPS acknowledges the command, process messages in response to the command on the client receive thread by invoking the provided handler. More...
std::string | executeAsyncNoResubscribe (Command &command_, MessageHandler handler_)
| Execute the provided command and, once AMPS acknowledges the command, process messages in response to the command on the client receive thread by invoking the provided handler. More...
MessageStream | execute (Command &command_)
| Execute the provided command and return messages received in response in a MessageStream. More...
void | ack (Field &topic_, Field &bookmark_, const char *options_=NULL)
| Acknowledge a message queue message by supplying a topic and bookmark: this adds the ack to the current batch (or sends the ack immediately if the batch size is 1 or less). More...
void | ack (Message &message_, const char *options_=NULL)
| Acknowledge a message queue message by supplying the message directly: this adds the ack to the current batch (or sends the ack immediately if the batch size is 1 or less). More...
void | ack (const std::string &topic_, const std::string &bookmark_, const char *options_=NULL)
| Acknowledge a message queue message by supplying a topic and bookmark string: this adds the ack to the current batch (or sends the ack immediately if the batch size is 1 or less). More...
void | flushAcks (void)
| Sends any queued message queue ack messages to the server immediately. More...
bool | getAutoAck (void) const
| Returns the value of the queue auto-ack setting. More...
void | setAutoAck (bool isAutoAckEnabled_)
| Sets the queue auto-ack setting on this client. More...
unsigned | getAckBatchSize (void) const
| Returns the value of the queue ack batch size setting. More...
void | setAckBatchSize (const unsigned ackBatchSize_)
| Sets the queue ack batch size setting. More...
int | getAckTimeout (void) const
| Returns the current value of the message queue ack timeout setting – that is, the amount of time after which queue messages will be acknowledged even if the ack batch is not full. More...
void | setAckTimeout (const int ackTimeout_)
| Sets the message queue ack timeout value. More...
void | setRetryOnDisconnect (bool isRetryOnDisconnect_)
| Enables or disables automatic retry of a command to AMPS after a reconnect. More...
bool | getRetryOnDisconnect (void) const
| Returns true if automatic retry of a command to AMPS after a reconnect is enabled.
void | setDefaultMaxDepth (unsigned maxDepth_)
| Sets a default max depth on all subsequently created `MessageStream` objects. More...
unsigned | getDefaultMaxDepth (void) const
| Returns the default max depth for returned `MessageStream` objects. More...
void | setTransportFilterFunction (amps_transport_filter_function filter_, void *userData_)
| Sets a filter function on the transport that is called with all raw data sent or received. More...
void | setThreadCreatedCallback (amps_thread_created_callback callback_, void *userData_)
| Sets a callback function on the transport that is called when a new thread is created to receive data from the server. More...
void | setPublishBatching (size_t batchSize_, amps_uint64_t batchTimeoutMillis_)
| Sets the max bytes to cache and max timeout in millis for caching delta_publish and publish commands. More...

## Static Public Member Functions
static HAClient | createMemoryBacked (const std::string &name_)
| Creates an HAClient with the given name that uses a memory-based Store for publish messages and a memory-based BookmarkStore for tracking messages received from bookmark subscriptions. More...
static HAClient | createFileBacked (const std::string &name_, const std::string &publishLogName_, const std::string &subscribeLogName_)
| Creates an HAClient with the given name that uses a file-based Store for publish messages that is named publishLogName_ and a file-based BookmarkStore for tracking messages received for bookmark subscriptions. More...
Static Public Member Functions inherited from AMPS::Client
static size_t | convertVersionToNumber (const std::string &version_)
| Converts a string version, such as "3.8.1.5" into the same numeric form used internally and returned by getServerVersion. More...
static size_t | convertVersionToNumber (const char *data_, size_t len_)
| Converts a string version, such as "3.8.1.5" into the same numeric form used internally and returned by getServerVersion. More...
static const char * | BOOKMARK_NOW ()
| Convenience method for returning the special value to start a subscription at the end of the transaction log. More...
static const char * | NOW ()
| Convenience method for returning the special value to start a subscription at the end of the transaction log. More...
static const char * | BOOKMARK_EPOCH ()
| Convenience method for returning the special value to start a subscription at the beginning of the transaction log. More...
static const char * | EPOCH ()
| Convenience method for returning the special value to start a subscription at the beginning of the transaction log. More...
static const char * | BOOKMARK_MOST_RECENT ()
| Convenience method for returning the special value to start a subscription at a recovery point based on the information that the configured BookmarkStore (if one is set) has for the subscription. More...
static const char * | MOST_RECENT ()
| Convenience method for returning the special value to start a subscription at a recovery point based on the information that the configured BookmarkStore (if one is set) has for the subscription. More...
static const char * | BOOKMARK_RECENT ()
| Convenience method for returning the special value to start a subscription at a recovery point based on the information that the configured BookmarkStore (if one is set) has for the subscription. More...

## Detailed Description

A highly-available Client that automatically reconnects and re-subscribes to AMPS instances upon disconnect.

An HAClient provides failover and resubscription functionality by default. For reliable publish, set a PublishStore for the HAClient (and, in most cases, set a FailedWriteHandler as well so the application can detect any failed publishes). For managing transaction log replays, set a bookmark store (such as LoggedBookmarkStore or MemoryBookmarkStore).

To connect to AMPS, you must provide a ServerChooser implementation to the HAClient. By default, the HAClient provides an ExponentialDelayStrategy with the default delay and backoff behavior for that class.

By default, the HAClient object has the reconnect and resubscribe functionality provided by the MemorySubscriptionManager and a default DisconnectHandler. It is typically not necessary to replace the disconnect handler or subscription manager for this class. Notice that replacing either of these defaults will change the failover, resubscription, and/or republish behavior of the HAClient.

See the Developer Guide for more information on using the HAClient.

## Constructor & Destructor Documentation

## ◆ HAClient() [1/3]

AMPS::HAClient::HAClient | ( | const std::string & | name_ | ) |
| inline

Create an HAClient with the given name.

Parameters

  name_ | Name for the client. This name is used for duplicate message detection and should be unique. AMPS does not enforce specific restrictions on the character set used, however some protocols (for example, XML) may not allow specific characters. 60East recommends that the client name be meaningful, short, human readable, and avoids using control characters, newline characters, or square brackets.

## ◆ HAClient() [2/3]

AMPS::HAClient::HAClient | ( | HAClientImpl * | body_ | ) |
| inline

Create an HAClient wrapping the given implementation, used internally.

Parameters

  body_ | The implementation for the client to wrap.

## ◆ HAClient() [3/3]

AMPS::HAClient::HAClient | ( | const HAClient & | rhs | ) |
| inline

Copy constructor, makes a new reference to the same body.

Parameters

  rhs | The HAClient to copy.

## Member Function Documentation

## ◆ connectAndLogon()

void AMPS::HAClient::connectAndLogon | ( |  | ) |
| inline

Connect and logon to AMPS using the server(s) from the ServerChooser set on this HAClient and the Authenticator set on this HAClient to to provide logon information.

Will continue attempting to connect and logon until successful or ServerChooser returns an empty URI.

## ◆ createFileBacked()

static HAClient AMPS::HAClient::createFileBacked | ( | const std::string & | name_,
|  | const std::string & | publishLogName_,
|  | const std::string & | subscribeLogName_
| ) |  |
| inline static

Creates an HAClient with the given name that uses a file-based Store for publish messages that is named publishLogName_ and a file-based BookmarkStore for tracking messages received for bookmark subscriptions.

This function is provided for convenience in cases where a given connection will both publish to AMPS and use bookmark subscriptions. The client returned uses PublishStore and MMapBookmarkStore, and is equivalent to constructing an HAClient and then setting those stores on the client. If the application is not both publishing and using bookmark subscriptions, it is recommended that you create the client and set whichever store is appropriate.

Parameters

  name_ | Name for the client. This name is used for duplicate message detection and should be distinct for this set of messages, and consistent across invocations of the application that use the same publish store file. AMPS does not enforce specific restrictions on the character set used, however some protocols (for example, XML) may not allow specific characters. 60East recommends that the client name be meaningful, short, human readable, and avoid using control characters, newline characters, or square brackets.
  publishLogName_ | The name for file used by the PublishStore.
  subscribeLogName_ | The name for the file used by the LoggedBookmarkStore.

Returns
  The HAClient created with given values.

## ◆ createMemoryBacked()

static HAClient AMPS::HAClient::createMemoryBacked | ( | const std::string & | name_ | ) |
| inline static

Creates an HAClient with the given name that uses a memory-based Store for publish messages and a memory-based BookmarkStore for tracking messages received from bookmark subscriptions.

This function is provided for convenience in cases where a given connection will both publish and use bookmark subscriptions. The client returned uses MemoryPublishStore and MemoryBookmarkStore, and is equivalent to constructing an HAClient and then setting those stores on the client. If the application is not both publishing and using a bookmark subscription, it is recommended that you create the client and set whichever store is appropriate. The MemoryPublishStore created by by this method has a capacity of 10000 blocks: if this is not a reasonable value for your application, create an HAClient and set the stores explicitly with the appropriate capacity.

Parameters

  name_ | Name for the client. This name is used for duplicate message detection and should be unique. AMPS does not enforce specific restrictions on the character set used, however some protocols (for example, XML) may not allow specific characters. 60East recommends that the client name be meaningful, short, human readable, and avoids using control characters, newline characters, or square brackets.

Returns
  The HAClient created with the name and the memory stores.

## ◆ disconnected()

bool AMPS::HAClient::disconnected | ( |  | ) | const
| inline

Return whether or not the client is disconnected.

Returns
  true if disconnected, false if connected.

## ◆ gatherConnectionInfo()

ConnectionInfo AMPS::HAClient::gatherConnectionInfo | ( |  | ) | const
| inline

Deprecated:
  Use getConnectionInfo().

Get the connection information for the current connection. This is a deprecated alias to getConnectionInfo.

Returns
  A ConnectionInfo object with the information describing the the current connection.

## ◆ getConnectionInfo()

ConnectionInfo AMPS::HAClient::getConnectionInfo | ( |  | ) | const
| inline virtual

Get the connection information for the current connection.

Returns
  A ConnectionInfo object with the information describing the the current connection.

Reimplemented from AMPS::Client.

## ◆ getLogonOptions()

std::string AMPS::HAClient::getLogonOptions | ( | void |  | ) | const
| inline

Get the options passed to the server during logon.

Returns
  The options passed to the server during logon.

## ◆ getReconnectDelay()

int AMPS::HAClient::getReconnectDelay | ( |  | ) | const
| inline

The current delay in milliseconds between reconnect attempts.

Returns
  The number of milliseconds to delay.

## ◆ getReconnectDelayStrategy()

ReconnectDelayStrategy AMPS::HAClient::getReconnectDelayStrategy | ( | void |  | ) | const
| inline

Get the ReconnectDelayStrategy used to control delay behavior when connecting and reconnecting to servers.

Returns
  The ReconnectDelayStrategy used when connecting and reconnecting to AMPS instances.

## ◆ getServerChooser()

ServerChooser AMPS::HAClient::getServerChooser | ( |  | ) | const
| inline

Return the ServerChooser currently used by the HAClient.

Returns
  The current ServerChooser.

## ◆ getTimeout()

int AMPS::HAClient::getTimeout | ( | void |  | ) | const
| inline

Get the current timeout used when attempting to log into AMPS.

Returns
  The number of milliseconds used for the logon timeout.

## ◆ operator=()

HAClient& AMPS::HAClient::operator= | ( | const HAClient & | rhs | ) |
| inline

Assignment operator, the body will be shared after this.

Parameters

  rhs | The HAClient to copy.

## ◆ setDisconnectHandler()

void AMPS::HAClient::setDisconnectHandler | ( | const DisconnectHandler & |  | ) |
| inline virtual

Deprecated:
  This function will be removed in future version.

Use a ConnectionStateListener to monitor the state of your connection. This function is over-ridden to throw an exception since the reconnect, republish, and resubscribe behavior for the HAClient class is provided through the disconnect handler, so setting a disconnect handler for the HAClient will completely replace the high-availability behavior of that client.

Reimplemented from AMPS::Client.

## ◆ setReconnectDelay()

void AMPS::HAClient::setReconnectDelay | ( | int | reconnectDelay_ | ) |
| inline

Set the delay between reconnect attempts in milliseconds.

This method constructs a new FixedDelayStrategy with the specified reconnect time and sets that as the delay strategy for the class.

Parameters

  reconnectDelay_ | The number of milliseconds to wait between attempts to reconnect when disconnected.

## ◆ setReconnectDelayStrategy()

void AMPS::HAClient::setReconnectDelayStrategy | ( | const ReconnectDelayStrategy & | strategy_ | ) |
| inline

Set the ReconnectDelayStrategy used to control delay behavior when connecting and reconnecting to servers.

Parameters

  strategy_ | The ReconnectDelayStrategy to use when connecting and reconnecting to AMPS instances.

## ◆ setServerChooser()

void AMPS::HAClient::setServerChooser | ( | const ServerChooser & | serverChooser_ | ) |
| inline

Set the ServerChooser used to determine the URI used when trying to connect and logon to AMPS.

Parameters

  serverChooser_ | The ServerChooser instance to use.

## ◆ setTimeout()

void AMPS::HAClient::setTimeout | ( | int | timeout_ | ) |
| inline

Set the timeout used when logging into AMPS.

Parameters

  timeout_ | The timeout, in milliseconds. 0 indicates no timeout.

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

- include/amps/HAClient.hpp