AMPS C# Client  5.3.3.4
AMPS C# Client for .NET
AMPS.Client.HAClient Class Reference

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

+ Inheritance diagram for AMPS.Client.HAClient:

Classes

class  HADisconnectHandler
 

Public Member Functions

void setReconnectDelay (int reconnectInterval)
 Sets the time delay between reconnection events. More...
 
HAClient setReconnectDelayStrategy (ReconnectDelayStrategy strategy_)
 Sets the ReconnectDelayStrategy for this client, replacing any previous strategy. More...
 
void setLogonOptions (string options_)
 Sets the options string passed in during logon. More...
 
string getLogonOptions ()
 Gets the options string passed in during logon. More...
 
void setTimeout (int timeout_)
 Sets the timeout for logon and re-subscribe sequence during a reconnection event. More...
 
int getTimeout ()
 Gets the timeout for logon and re-subscribe sequence during a reconnection event. More...
 
ServerChooser getServerChooser ()
 Returns the current ServerChooser for this client More...
 
void setServerChooser (ServerChooser serverChooser_)
 Sets the ServerChooser for this client More...
 
 HAClient (string name)
 Constructs a new "highly-available" HAClient More...
 
void connectAndLogon ()
 Connects to the next server chosen for us by our ServerChooser. Will continue attempting to connect and logon to each successive URI returned by the ServerChooser until the connection succeeds or the ServerChooser returns an empty URI. More...
 
override void connect (string uri)
 Connects to the AMPS instance through the provided URI. The URI is a String with the format: More...
 
override CommandId logon ()
 Logs into AMPS with the parameters provided in the connect method. More...
 
override CommandId logon (long timeout)
 Logs into AMPS with the parameters provided in the connect method and the logon correlation data if set. More...
 
override CommandId logon (long timeout, Authenticator authenticator)
 Logs into AMPS with the parameters provided in the connect method and the logon correlation data if set. More...
 
override CommandId logon (string options)
 Logs into AMPS with the parameters provided in the connect method and the logon correlation data if set. More...
 
override CommandId logon (long timeout, string options)
 Logs into AMPS with the parameters provided in the connect method and the logon correlation data if set. More...
 
override CommandId logon (long timeout, Authenticator authenticator, string options)
 Logs into AMPS with the parameters provided in the connect method and the logon correlation data if set. More...
 
override void disconnect ()
 Disconnect from the AMPS server. More...
 
override ConnectionInfo getConnectionInfo ()
 
- Public Member Functions inherited from AMPS.Client.Client
delegate void ExceptionListener (Exception e)
 
 Client (String name)
 Creates a new AMPS client More...
 
 Client (String name, int version)
 Creates a new client More...
 
 Client (String name, Store store)
 Creates a client with a persistent store. More...
 
 Client (String name, Store store, int version)
 Creates a client with a persistent store. More...
 
 Client (String name, Transport transport)
 Creates a client with a transport. More...
 
 Client (String name, Transport transport, int version)
 Creates a client with a transport. More...
 
 Client (String name, Transport transport, Store store)
 Creates a client with a transport and persistent store. More...
 
 Client (String name, Transport transport, Store store, int version)
 Creates a client with a transport and persistent store. More...
 
String getName ()
 Return the name of the Client. More...
 
String getNameHash ()
 Return the name hash of the Client as returned by the server after logon. More...
 
int getServerVersion ()
 Return the server version retrieved during logon. If the client has not logged on or is connected to a server whose version is less than 3.8.0.0 this function will return 0. The version uses 2 digits each for major minor maintenance and hotfix i.e., 3.8.1.5 will return 3080105 Versions of AMPS prior to 3.8.0.0 did not return the server version to the client in the logon ack. More...
 
VersionInfo getServerVersionInfo ()
 Return the server version retrieved during logon. If the client has not logged on or is connected to a server whose version is less than 3.8.0.0 this function will return the latest release version. The version is returned as a VersionInfo. Versions of AMPS prior to 3.8.0.0 did not return the server version to the client in the logon ack. More...
 
Uri getURI ()
 Returns the URI the client is connected to. More...
 
Transport getTransport ()
 Return the underlying transport. For advanced users, this method provides direct access to the transport. Care needs to be taken to not modify the underlying transport in ways that are incompatible with the Client. More...
 
void setBookmarkStore (BookmarkStore val)
 
BookmarkStore getBookmarkStore ()
 
void setPublishStore (Store store)
 
Store getPublishStore ()
 
void setDisconnectHandler (ClientDisconnectHandler disconnectHandler)
 Sets the ClientDisconnectHandler . In the event that the Client is unintentionally disconnected from AMPS, the More...
 
void setDisconnectHandler (Action< Client > disconnectHandler)
 Sets the lambda function called in the event of client disconnect More...
 
ClientDisconnectHandler getDisconnectHandler ()
 Gets the currently configured ClientDisconnectHandler More...
 
void setLastChanceMessageHandler (MessageHandler messageHandler)
 Sets the MessageHandler instance used when no other handler matches. More...
 
void setLastChanceMessageHandler (Action< Message > messageHandler)
 Sets the MessageHandler instance used when no other handler matches. More...
 
void setUnhandledMessageHandler (MessageHandler messageHandler)
 Sets the MessageHandler instance used when no other handler matches. More...
 
void setUnhandledMessageHandler (Action< Message > messageHandler)
 Sets the lambda function used when no other handler matches. More...
 
void setExceptionListener (ExceptionListener exceptionListener)
 Sets the ExceptionListener instance used for communicating absorbed exceptions. More...
 
ExceptionListener getExceptionListener ()
 Gets the currently configured ExceptionListener More...
 
void setSubscriptionManager (SubscriptionManager subscriptionManager)
 Sets the SubscriptionManager instance used for recording active subscriptions. More...
 
SubscriptionManager getSubscriptionManager ()
 Gets the currently configured SubscriptionManager More...
 
void setGlobalCommandTypeMessageHandler (string command_, MessageHandler messageHandler_)
 Sets the MessageHandler that will be called in the event of a message of the given command type. More...
 
void setGlobalCommandTypeMessageHandler (Message.Commands command_, MessageHandler messageHandler_)
 Sets the MessageHandler that will be called in the event of a message of the given command type. More...
 
void setGlobalCommandTypeMessageHandler (GlobalCommandTypeHandlers command_, MessageHandler messageHandler_)
 Sets the MessageHandler that will be called in the event of a message of the given command type. More...
 
void setDuplicateMessageHandler (MessageHandler messageHandler)
 Sets the MessageHandler that will be called in the event of a duplicate message More...
 
MessageHandler getDuplicateMessageHandler ()
 Returns the MessageHandler that will be called in the event of a duplicate message More...
 
void setFailedWriteHandler (FailedWriteHandler handler_)
 Sets the FailedWriteHandler instance that will be called in the event that messages fail to be written More...
 
void setFailedWriteHandler (FailedWriteHandlerV4 handler_)
 Sets the FailedWriteHandlerV4 instance that will be called in the event that messages fail to be written More...
 
FailedWriteHandler getFailedWriteHandler ()
 Returns the the FailedWriteHandler instance that will be called in the event that messages fail to be written More...
 
void close ()
 Disconnect from the AMPS server. More...
 
Message allocateMessage ()
 Creates a new Message appropriate for this client. This function should be called rarely, since it does allocate a handful of small objects. Users sensitive to garbage collection delays should cache the message object for later usage. More...
 
virtual void setHeartbeat (int heartbeatInterval_, int readTimeout_)
 Sets a heartbeat on this connection. When a heartbeat is set, the client periodically sends a heartbeat message to AMPS. This helps the client more quickly detect disconnection from AMPS. More...
 
void setHeartbeat (int heartbeatInterval_)
 Sets a heartbeat on this connection. When a heartbeat is set, the client periodically sends a heartbeat message to AMPS. This helps the client more quickly detect disconnection from AMPS. More...
 
void send (Message m)
 Send a Message to AMPS via the Transport used in the Client. More...
 
void addMessageHandler (CommandId commandId_, MessageHandler messageHandler_, Message.AckTypes requestedAcks_, bool isSubscribe_)
 Adds a MessageHandler for a given CommandId to self. More...
 
bool removeMessageHandler (CommandId commandId_)
 
void setRetryOnDisconnect (bool isRetryOnDisconnect)
 Set whether or not messages being sent to the server should retry if the client is disconnected. This is most useful if you are publishing data that has a very short lifetime and so is no longer relevant after the time it takes to reconnect. More...
 
bool getRetryOnDisconnect ()
 Return whether or not messages being sent to the server will retry if the client is disconnected. More...
 
void setDefaultMaxDepth (int defaultMaxDepth)
 Set the default max depth to be used on all MessageStream results. More...
 
int getDefaultMaxDepth ()
 Return the current default max depth value set on MessageStream results. More...
 
CommandId send (MessageHandler messageHandler, Message message, long timeout)
 Send a Message to AMPS and register the messageHandler for any messages resulting from command execution. More...
 
CommandId send (Action< Message > messageHandler, Message message, long timeout)
 Send a Message to AMPS and register the messageHandler for any messages resulting from command execution. More...
 
ulong publish (byte[] topic, int topicOffset, int topicLength, byte[] data, int dataOffset, int dataLength, int expiration)
 Publish a message to an AMPS topic. If the client has a publish store set, More...
 
ulong publish (byte[] topic, int topicOffset, int topicLength, byte[] data, int dataOffset, int dataLength)
 Publish a message to an AMPS topic. If the client has a publish store set, More...
 
ulong publish (String topic, String data)
 Publish a message to an AMPS topic. If the client has a publish store set, More...
 
ulong publish (String topic, String data, int expiration)
 Publish a message to an AMPS topic. If the client has a publish store set, More...
 
ulong deltaPublish (byte[] topic, int topicOffset, int topicLength, byte[] data, int dataOffset, int dataLength)
 Delta publish a message to an AMPS topic. If the client has a publish store set, More...
 
ulong deltaPublish (byte[] topic, int topicOffset, int topicLength, byte[] data, int dataOffset, int dataLength, int expiration)
 Delta publish a message to an AMPS topic. If the client has a publish store set, More...
 
ulong deltaPublish (String topic, String data)
 Delta publish a message to an AMPS topic. If the client has a publish store set, More...
 
ulong deltaPublish (String topic, String data, int expiration)
 Delta publish a message to an AMPS topic. If the client has a publish store set, More...
 
CommandId bookmarkSubscribe (MessageHandler messageHandler, String topic, String filter=null, CommandId subId=null, String bookmark=null, string options=null, long timeout=0)
 Places a bookmark subscription with AMPS. Starts replay at the most recent message reported by the BookmarkStore. More...
 
CommandId subscribe (MessageHandler messageHandler, String topic, String filter, long timeout)
 Places a subscription with AMPS. More...
 
CommandId subscribe (Action< Message > messageHandler, String topic, String filter, long timeout)
 Places a subscription with AMPS. More...
 
MessageStream subscribe (string topic, string filter=null, string options=null, long timeout=0, string subid=null)
 Places a subscription with AMPS. More...
 
CommandId subscribe (MessageHandler messageHandler, String topic, String filter=null, string options=null, long timeout=0, String subId=null)
 Places a subscription with AMPS. More...
 
CommandId subscribe (Action< Message > messageHandler, String topic, String filter=null, String options=null, long timeout=0, string subid=null)
 Places a subscription with AMPS. More...
 
CommandId subscribe (MessageHandler messageHandler, String topic, long timeout)
 Places a subscription with AMPS. More...
 
CommandId subscribe (Action< Message > messageHandler, String topic, long timeout)
 Places a subscription with AMPS. More...
 
CommandId deltaSubscribe (MessageHandler messageHandler, String topic, String filter=null, String options=null, long timeout=0, String subId=null)
 Places a delta subscription with AMPS. More...
 
CommandId deltaSubscribe (Action< Message > messageHandler, String topic, String filter=null, String options=null, long timeout=0, String subId=null)
 Places a delta subscription with AMPS. More...
 
void unsubscribe (CommandId subscriptionId)
 Remove a subscription from AMPS. More...
 
void unsubscribe ()
 Remove all of the client's subscriptions from AMPS. More...
 
MessageStream sow (String topic, String filter=null, String orderBy=null, String bookmark=null, String options=null, int batchSize=10, int topN=-1, long timeout=0)
 Executes a SOW query. More...
 
CommandId sow (MessageHandler messageHandler, String topic, String filter=null, String orderBy=null, String bookmark=null, String options=null, int batchSize=10, int topN=-1, long timeout=0)
 Executes a SOW query. More...
 
CommandId sow (Action< Message > messageHandler, String topic, String filter=null, String orderBy=null, String bookmark=null, String options=null, int batchSize=10, int topN=-1, long timeout=0)
 Executes a SOW query. More...
 
CommandId sow (MessageHandler messageHandler, String topic, String filter, int batchSize, long timeout)
 Executes a SOW query. More...
 
CommandId sow (MessageHandler messageHandler, String topic, int batchSize, long timeout)
 Executes a SOW query. More...
 
CommandId sow (Action< Message > messageHandler, String topic, int batchSize, long timeout)
 Executes a SOW query. More...
 
CommandId sow (MessageHandler messageHandler, String topic, long timeout)
 Executes a SOW query. More...
 
CommandId sow (Action< Message > messageHandler, String topic, long timeout)
 Executes a SOW query. More...
 
MessageStream sowAndSubscribe (String topic, String filter=null, String orderBy=null, String bookmark=null, String options=null, int batchSize=10, int topN=-1, long timeout=0)
 Executes a SOW query and places a subscription. More...
 
CommandId sowAndSubscribe (MessageHandler messageHandler, String topic, String filter=null, String orderBy=null, String bookmark=null, String options=null, int batchSize=10, int topN=-1, long timeout=0)
 Executes a SOW query and places a subscription. More...
 
CommandId sowAndSubscribe (Action< Message > messageHandler, String topic, String filter=null, String orderBy=null, String bookmark=null, String options=null, int batchSize=10, int topN=-1, long timeout=0)
 Executes a SOW query and places a subscription. More...
 
CommandId sowAndSubscribe (MessageHandler messageHandler, String topic, String filter, int batchSize, bool oofEnabled, long timeout)
 Executes a SOW query and places a subscription. More...
 
CommandId sowAndSubscribe (Action< Message > a, String topic, String filter, int batchSize, bool sendOOF, long timeout)
 Executes a SOW query and places a subscription. More...
 
CommandId sowAndSubscribe (MessageHandler messageHandler, String topic, int batchSize, long timeout)
 Executes a SOW query and places a subscription. More...
 
CommandId sowAndSubscribe (Action< Message > a, String topic, int batchSize, long timeout)
 Executes a SOW query and places a subscription. More...
 
CommandId sowAndSubscribe (MessageHandler messageHandler, String topic, long timeout)
 Executes a SOW query and places a subscription. More...
 
CommandId sowAndSubscribe (Action< Message > a, String topic, long timeout)
 Executes a SOW query and places a subscription. More...
 
CommandId sowAndDeltaSubscribe (MessageHandler messageHandler, String topic, String filter=null, String orderBy=null, String bookmark=null, String options=null, int batchSize=10, int topN=-1, long timeout=0)
 Executes a SOW query and places a delta subscription. More...
 
CommandId sowAndDeltaSubscribe (MessageHandler messageHandler, String topic, String filter, int batchSize, bool oofEnabled, bool sendEmpties, long timeout)
 Executes a SOW query and places a delta subscription. More...
 
CommandId sowAndDeltaSubscribe (Action< Message > messageHandler, String topic, String filter, int batchSize, bool oofEnabled, bool sendEmpties, long timeout)
 Executes a SOW query and places a delta subscription. More...
 
CommandId sowAndDeltaSubscribe (MessageHandler messageHandler, String topic, int batchSize, long timeout)
 Executes a SOW query and places a delta subscription. More...
 
CommandId sowAndDeltaSubscribe (Action< Message > messageHandler, String topic, int batchSize, long timeout)
 Executes a SOW query and places a delta subscription. More...
 
CommandId sowAndDeltaSubscribe (MessageHandler messageHandler, String topic, long timeout)
 Executes a SOW query and places a delta subscription. More...
 
CommandId sowAndDeltaSubscribe (Action< Message > messageHandler, String topic, long timeout)
 Executes a SOW query and places a delta subscription. More...
 
Message sowDelete (String topic, String filter, long timeout=0)
 Executes a SOW delete with filter. More...
 
CommandId sowDelete (MessageHandler messageHandler, String topic, String filter, long timeout=0)
 Executes a SOW delete with filter. More...
 
CommandId sowDelete (Action< Message > messageHandler, String topic, String filter, long timeout=0)
 Executes a SOW delete with filter. More...
 
void startTimer ()
 
CommandId stopTimer (MessageHandler messageHandler, long timeout)
 
void setLogonCorrelationData (String correlationData)
 Gets the uninterpreted logon correlation information currently set. More...
 
String getLogonCorrelationData ()
 Gets the uninterpreted logon correlation information currently set. More...
 
CommandId sowDeleteByKeys (MessageHandler messageHandler, String topic, String keys, long timeout=0)
 Executes a SOW delete by sow key. More...
 
CommandId sowDeleteByKeys (Action< Message > messageHandler, String topic, String keys, long timeout=0)
 Executes a SOW delete by sow key. More...
 
CommandId sowDeleteByData (MessageHandler messageHandler, String topic, String data, long timeout=0)
 Executes a SOW delete by data. AMPS uses key fields in the data to find and delete a message with the same keys. More...
 
CommandId sowDeleteByData (Action< Message > messageHandler, String topic, String data, long timeout=0)
 Executes a SOW delete by data. AMPS uses key fields in the data to find and delete a message with the same keys. More...
 
void publishFlush ()
 Ensures that AMPS messages are sent and have been processed by the AMPS server. The client issues a flush command and waits for an acknowledgement. This mehthod blocks until messages have been processed and is most useful when the application reaches a point at which it is acceptable to block to ensure that messages are delivered to the AMPS server. For example, an application might call publishFlush before exiting. One thing to note is that if AMPS is unavailable (HA Client), publishFlush needs to wait for a connection to come back up which may look like it's hanging.
 
void publishFlush (int timeout)
 Ensures that AMPS messages are sent and have been processed by the AMPS server. The client issues a flush command and waits for an acknowledgement or until the timeout expires. This mehthod blocks until messages have been processed and is most useful when the application reaches a point at which it is acceptable to block to ensure that messages are delivered to the AMPS server. For example, an application might call publishFlush before exiting. One thing to note is that if AMPS is unavailable (HA Client), publishFlush needs to wait for a connection to come back up which may look like it's hanging.

Parameters
timeoutNumber of milliseconds to wait for flush, where 0 indicates no timeout

 
void publishFlush (string ackType_)
 Ensures that AMPS messages are sent and have been processed by the AMPS server. The client issues a flush command and waits for an acknowledgement. This mehthod blocks until messages have been processed and is most useful when the application reaches a point at which it is acceptable to block to ensure that messages are delivered to the AMPS server. For example, an application might call publishFlush before exiting. One thing to note is that if AMPS is unavailable (HA Client), publishFlush needs to wait for a connection to come back up which may look like it's hanging.

Parameters
ackType_The acknowledgement type that the flush command should wait to receive, see Message.AckType. 'processed' matches the timeout only version of this function. persisted ensures all previous messages have been persisted.

 
void publishFlush (string ackType_, int timeout)
 Ensures that AMPS messages are sent and have been processed by the AMPS server. The client issues a flush command and waits for an acknowledgement or until the timeout expires. This mehthod blocks until messages have been processed and is most useful when the application reaches a point at which it is acceptable to block to ensure that messages are delivered to the AMPS server. For example, an application might call publishFlush before exiting. One thing to note is that if AMPS is unavailable (HA Client), publishFlush needs to wait for a connection to come back up which may look like it's hanging.

Parameters
ackType_The acknowledgement type that the flush command should wait to receive, see Message.AckType. 'processed' matches the timeout only version of this function. persisted ensures all previous messages have been persisted.
Parameters
timeoutNumber of milliseconds to wait for flush, where 0 indicates no timeout

 
long flush ()
 
long flush (long timeout)
 Clear the queued messages which may be waiting in the transport More...
 
void setThreadCreatedHandler (ThreadCreatedHandler handler_)
 Set a handler that is invoked immediately by any thread created by the transport. More...
 
void setThreadCreatedHandler (Action handler_)
 Set a handler that is invoked immediately by any thread created by the transport. More...
 
void setTransportFilter (TransportFilter filter_)
 Sets a TransportFilter that filters raw bytes bfeore send and after receive. More...
 
void ack (byte[] topic, int topicPos, int topicLen, byte[] bookmark, int bookmarkPos, int bookmarkLen, byte[] options=null, int optionsPos=0, int optionsLen=0)
 ACKs a message queue message. More...
 
void ack (Field topic, Field bookmark, Field options=null)
 ACKs a message queue message. More...
 
void ack (String topic, String bookmark, String options=null)
 ACKS a message queue message. More...
 
void setAutoAck (bool isAutoAckEnabled)
 Enables or disables auto-acking. When auto-acking is enabled any successful return from a message handler functiokn will result in an ACK (sow_delete) message sent to the server. Any thrown exception will result in a "cancel" ACK sent to the server. More...
 
bool getAutoAck ()
 Returns the current setting of auto-acking. More...
 
void setAckBatchSize (int batchSize)
 Sets the current ACK batch size.The ACK batch size controls how many successful ACKs (which are sow_delete messages) are batched together before sending to the server.When combined with the "max_backlog" and MaxPerSubscriptionBacklog server configuration parameter, greater network efficiency can be achieved when using message queues.Setting this parameter causes calls to "ack" and successful auto-acks to be batched; unsuccessful/cancel acks are sent immediately. More...
 
int getAckBatchSize ()
 Returns the current ACK batch size. See the documentation for setAckBatchSize(int). More...
 
void setAckTimeout (long ackTimeout)
 Sets the ack timeout – the maximum time to let a success ack be cached before sending. More...
 
long getAckTimeout ()
 Returns the queue ack timeout. More...
 
void flushAcks ()
 Sends any pending queue ACKs to the server. More...
 
CommandId executeAsync (Command command, MessageHandler handler=null)
 Execute the provided command and process responses on the client receive thread using the provided handler. More...
 
CommandId executeAsync (Command command, Action< Message > action)
 Execute the provided command on a background thread and provide messages received in response to the handler provided. More...
 
MessageStream execute (Command command)
 Execute the provided command and return messages received in response in a MessageStream. More...
 
void Dispose ()
 

Static Public Member Functions

static HAClient createMemoryBacked (string name)
 Creates a new memory-backed highly-available HAClient . This HAClient will automatically reconnect and re-subscribe in the event of a disconnect, and uses memory to ensure messages are not lost and duplicates are processed appropriately. This is equivalent to creating an More...
 
static HAClient createFileBacked (string name, string publishLog, string subscribeLog)
 Creates a new "highly-available" HAClient backed by disk. This HAClient will automatically reconnect and re-subscribe in the event of a disconnect. It uses disk to ensure messages are not lost and duplicates are processed appropriately. This is equivalent to creating an More...
 
- Static Public Member Functions inherited from AMPS.Client.Client
static int getVersionAsInt (String version)
 Return the numeric value for the given version string with the pattern: Major.Minor.Maintenance.Hotfix The version uses 2 digits each for major minor maintenance and hotfix i.e., 3.8.1.5 will return 3080105 Version strings passed in can be shortened to not include all levels so 3.8 will return 3080000. More...
 
static String getVersion ()
 Return the build number for the client that is stored in the Manifest.mf of the jar file. More...
 

Additional Inherited Members

- Public Types inherited from AMPS.Client.Client
enum class  GlobalCommandTypeHandlers : int {
  Publish = 0 , SOW = 1 , GroupBegin = 2 , GroupEnd = 3 ,
  Heartbeat = 4 , OOF = 5 , Ack = 6 , LastChance = 7 ,
  DuplicateMessage = 8 , COUNT = 9
}
 Used to specify what type of command should be directed to a global handler when it is set. All messages of this type will be sent to the handler in addition to any handlers set for the specific command, subscription, or query id in the message. More...
 
- Static Public Attributes inherited from AMPS.Client.Client
const int MIN_MULTI_BOOKMARK_VERSION = 4000000
 
const int MIN_QUEUE_VERSION = 5000000
 
- Protected Member Functions inherited from AMPS.Client.Client
void broadcastConnectionStateChangedEvent (ConnectionStateChangedEventArgs args)
 
- Protected Attributes inherited from AMPS.Client.Client
ExceptionListener _exceptionListener = null
 
Object internalLock = new Object()
 
volatile int _lastFailedConnectionVersion = -1
 
- Properties inherited from AMPS.Client.Client
bool AutoAck [get, set]
 The AutoAck property enables or disables auto-acking. When auto-acking is enabled any successful return from a message handler function will result in an ACK (sow_delete) message sent to the server. Any thrown exception will result in a "cancel" ACK sent to the server. More...
 
int AckBatchSize [get, set]
 The ACK batch size controls how many successful ACKs (which are sow_delete messages) are batched together before sending to the server.When combined with the "max_backlog" and MaxPerSubscriptionBacklog server configuration parameter, greater network efficiency can be achieved when using message queues.Setting this parameter causes calls to "ack" and successful auto-acks to be batched; unsuccessful/cancel acks are sent immediately. More...
 
- Events inherited from AMPS.Client.Client
EventHandler< ConnectionStateChangedEventArgsConnectionStateChanged
 

Detailed Description

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

An HAClient object 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 BookmarkStore.

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

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

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

Constructor & Destructor Documentation

◆ HAClient()

AMPS.Client.HAClient.HAClient ( string  name)
inline

Constructs a new "highly-available" HAClient

Parameters
nameA name to identify this 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 avoid using control characters, newline characters, or square brackets.

Member Function Documentation

◆ connect()

override void AMPS.Client.HAClient.connect ( string  uri)
inlinevirtual

Connects to the AMPS instance through the provided URI. The URI is a String with the format:

transport://user:password@host:port/protocol

The elements in the URI string are as follows:

  • transport – the network transport used for the connection
  • user(optional) the userId used to authenticate the connection
  • password(optional) the password used to authenticate the connection
  • host – the hostname or IP address of the host where AMPS is running
  • port – the port to connect to
  • protocol – the protocol used for the connection
Parameters
uriThe URI string to connect to
Exceptions
ConnectionRefusedExceptionThe connection could not be established
AlreadyConnectedExceptionThe connection is already connected
InvalidURIExceptionThe specified URI is invalid
ProtocolExceptionThe protocol is invalid
TransportTypeExceptionThe transport type is invalid

Reimplemented from AMPS.Client.Client.

◆ connectAndLogon()

void AMPS.Client.HAClient.connectAndLogon ( )
inline

Connects to the next server chosen for us by our ServerChooser. Will continue attempting to connect and logon to each successive URI returned by the ServerChooser until the connection succeeds or the ServerChooser returns an empty URI.

Exceptions
ConnectionExceptionConnection to AMPS instance failed

◆ createFileBacked()

static HAClient AMPS.Client.HAClient.createFileBacked ( string  name,
string  publishLog,
string  subscribeLog 
)
inlinestatic

Creates a new "highly-available" HAClient backed by disk. This HAClient will automatically reconnect and re-subscribe in the event of a disconnect. It uses disk to ensure messages are not lost and duplicates are processed appropriately. This is equivalent to creating an

HAClient and setting a LoggedBookmarkStore and a PublishStore on the client. If your application does not both publish to AMPS and use a bookmark replay, constructing an HAClient and setting the stores explicitly is recommended.

Parameters
nameA name to identify this 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 avoid using control characters, newline characters, or square brackets.
publishLogFile path to store the publisher log
subscribeLogFile path to the subscriber log

◆ createMemoryBacked()

static HAClient AMPS.Client.HAClient.createMemoryBacked ( string  name)
inlinestatic

Creates a new memory-backed highly-available HAClient . This HAClient will automatically reconnect and re-subscribe in the event of a disconnect, and uses memory to ensure messages are not lost and duplicates are processed appropriately. This is equivalent to creating an

HAClient and setting a MemoryBookmarkStore and a MemoryPublishStore for the client, where the MemoryPublishStore will have a capacity of 10000 blocks. If your application does not both publish to AMPS and use a bookmark replay, or if a capacity of 10000 blocks isn't a useful size for your MemoryPublishStore , constructing an HAClient and setting the stores explicitly is recommended.

Parameters
nameA name to identify this 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 avoid using control characters, newline characters, or square brackets.
Returns
A new memory backed HAClient instance

◆ disconnect()

override void AMPS.Client.HAClient.disconnect ( )
inlinevirtual

Disconnect from the AMPS server.

Reimplemented from AMPS.Client.Client.

◆ getConnectionInfo()

override ConnectionInfo AMPS.Client.HAClient.getConnectionInfo ( )
inlinevirtual

<sumamry> Assembles a new ConnectionInfo with the state of this client and associated classes.

Returns
A new ConnectionInfo object.

Reimplemented from AMPS.Client.Client.

◆ getLogonOptions()

string AMPS.Client.HAClient.getLogonOptions ( )
inline

Gets the options string passed in during logon.

Returns
logon options

◆ getServerChooser()

ServerChooser AMPS.Client.HAClient.getServerChooser ( )
inline

Returns the current ServerChooser for this client

Returns

◆ getTimeout()

int AMPS.Client.HAClient.getTimeout ( )
inline

Gets the timeout for logon and re-subscribe sequence during a reconnection event.

Returns
logon and re-subscribe timeout

◆ logon() [1/6]

override CommandId AMPS.Client.HAClient.logon ( )
inlinevirtual

Logs into AMPS with the parameters provided in the connect method.

Returns
The command identifier
Exceptions
TimedOutExceptionThe command execution exceeded the timeout value
DisconnectedExceptionThe connection was disconnected at time of send
AuthenticationExceptionAn authentication exception occured while logging on.

Reimplemented from AMPS.Client.Client.

◆ logon() [2/6]

override CommandId AMPS.Client.HAClient.logon ( long  timeout)
inlinevirtual

Logs into AMPS with the parameters provided in the connect method and the logon correlation data if set.

Parameters
timeoutThe number of milliseconds to wait for the command to execute, where 0 indicates no timeout
Returns
The command identifier
Exceptions
DisconnectedExceptionThe connection was disconnected at time of send
AuthenticationExceptionAn authentication exception occured while logging on.

Reimplemented from AMPS.Client.Client.

◆ logon() [3/6]

override CommandId AMPS.Client.HAClient.logon ( long  timeout,
Authenticator  authenticator 
)
inlinevirtual

Logs into AMPS with the parameters provided in the connect method and the logon correlation data if set.

Parameters
timeoutThe number of milliseconds to wait for the command to execute, where 0 indicates no timeout
authenticatorThe authenticator to use for logging in.
Returns
The command identifier
Exceptions
DisconnectedExceptionThe connection was disconnected at time of send
AuthenticationExceptionAn authentication exception occured while logging on.

Reimplemented from AMPS.Client.Client.

◆ logon() [4/6]

override CommandId AMPS.Client.HAClient.logon ( long  timeout,
Authenticator  authenticator,
string  options 
)
inlinevirtual

Logs into AMPS with the parameters provided in the connect method and the logon correlation data if set.

Parameters
timeoutThe number of milliseconds to wait for the command to execute, where 0 indicates no timeout
authenticatorThe authenticator to use for logging in.
optionsThe options string to pass on to the server during logon.
Returns
The command identifier
Exceptions
DisconnectedExceptionThe connection was disconnected at time of send
AuthenticationExceptionAn authentication exception occured while logging on.

Reimplemented from AMPS.Client.Client.

◆ logon() [5/6]

override CommandId AMPS.Client.HAClient.logon ( long  timeout,
string  options 
)
inlinevirtual

Logs into AMPS with the parameters provided in the connect method and the logon correlation data if set.

Parameters
timeoutThe number of milliseconds to wait for the command to execute, where 0 indicates no timeout
optionsThe options string to pass on to the server during logon.
Returns
The command identifier
Exceptions
DisconnectedExceptionThe connection was disconnected at time of send
AuthenticationExceptionAn authentication exception occured while logging on.

Reimplemented from AMPS.Client.Client.

◆ logon() [6/6]

override CommandId AMPS.Client.HAClient.logon ( string  options)
inlinevirtual

Logs into AMPS with the parameters provided in the connect method and the logon correlation data if set.

Parameters
optionsThe options string to pass on to the server during logon.
Returns
The command identifier
Exceptions
DisconnectedExceptionThe connection was disconnected at time of send
AuthenticationExceptionAn authentication exception occured while logging on.

Reimplemented from AMPS.Client.Client.

◆ setLogonOptions()

void AMPS.Client.HAClient.setLogonOptions ( string  options_)
inline

Sets the options string passed in during logon.

Parameters
options_logon options

◆ setReconnectDelay()

void AMPS.Client.HAClient.setReconnectDelay ( int  reconnectInterval)
inline

Sets the time delay between reconnection events.

Parameters
reconnectIntervaldelay between reconnection events.

When called, this method creates and installs a new FixedDelayStrategy in the client.

◆ setReconnectDelayStrategy()

HAClient AMPS.Client.HAClient.setReconnectDelayStrategy ( ReconnectDelayStrategy  strategy_)
inline

Sets the ReconnectDelayStrategy for this client, replacing any previous strategy.

Parameters
strategy_the strategy to install in this client

◆ setServerChooser()

void AMPS.Client.HAClient.setServerChooser ( ServerChooser  serverChooser_)
inline

Sets the ServerChooser for this client

Parameters
serverChooser_ServerChooser to set

◆ setTimeout()

void AMPS.Client.HAClient.setTimeout ( int  timeout_)
inline

Sets the timeout for logon and re-subscribe sequence during a reconnection event.

Parameters
timeout_logon and re-subscribe timeout, where 0 indicates no timeout

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