Bases: exceptions.Exception
The base exception class for all exceptions in the AMPS Python Client.
Bases: AMPS.ConnectionException
deprecated - use AlreadyConnectedException
Bases: AMPS.AlreadyConnected
The AlreadyConnectedExcpetion is raised when a client attemptsmultiple connections to an AMPS instance after being successfullyconnected.
Bases: AMPS.ConnectionException
deprecated - use AuthenticationException
Bases: AMPS.AuthenticationError
The AuthenticationException is raised when the credentials provided to the client fail in AMPS authentication.
Bases: AMPS.CommandException
deprecated - use BadFilterException
Bases: AMPS.BadFilter
The BadFilterException is raised when a query contains invalid content or is not used against a valid topic or field.
Bases: AMPS.CommandException
deprecated - use BadRegexTopicException
Bases: AMPS.BadRegexTopic
The BadRegexTopicException is raised when a topic query containing a regular expression is unable to be compiled by the AMPS regular expression compiler.
Bases: object
Wraps a C/C++ message handler function for use as a higher-performance AMPS message handler. To use, create a shared library or DLL with an exported function of type AMPS::MessageHandlerFunc, for example:
extern “C” void my_message_handler(const AMPS::Message& message, void* userdata) { ... }
and then use the python ctypes module to load and supply it:
import ctypes
client = AMPS.Client(...) ... my_dll = ctypes.CDLL(”./mymessagehandler.so”) # load my DLL client.subscribe( AMPS.CMessageHandler( my_dll.my_message_handler, “user data”), “my_amps_topic” )
Bases: object
The base AMPS Client object used in AMPS applications. Each Client object manages a single connection to AMPS. Each AMPS connection has a name, a specific transport (such as tcp), a protocol (used for framing messages to AMPS), and a message type (such as FIX or JSON).
The Client object creates and manages a background thread, and sends and receives messages on that thread. The object provides both a synchronous interface for processing messages on the calling thread, and an asynchronous interface suitable for populating a queue to be processed by worker threads.
Each Client has a name. The AMPS server uses this name for duplicate message detection, so the name of each instance of the client application should be unique.
An example of a simple Python client publishing a JSON message is listed below:
c = Client("test_client") try: c.connect("tcp://127.0.0.1:9004/json") cid = c.logon() c.publish("topic_name",'{"a":1,"b":"2"}') finally: c.close()
Constructor arguments:
Parameters: | name – the unique name for this client. 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. |
---|
Bases: object
This class provides special values for bookmark subscriptions:
- EPOCH begin the subscription at the beginning of the journal
- MOST_RECENT begin the subscription at the first undiscarded message in the bookmark store, or at the end of the bookmark store if all messages have been discarded
- NOW begin the subscription at the time that AMPS processes the subscription
For example, to begin a bookmark subscription at the beginning of the journal, provide AMPS.Client.Bookmarks.EPOCH as the bookmark in the call to AMPS.Client.bookmark_subscribe().
Bases: object
AMPS ConnectionStateListener type used to determine the new connection state.
ACKs a message queue message.
:param message an AMPS.Message object to ack, OR :param topic The topic of the message to ACK :param bookmark The bookmark of the message to ACK. :param options An optional string to include in the ACK such as ‘cancel’.
Sets a function to be called when this client connects or disconnects from AMPS.
Parameters: | listener_callable (A python function or other callable that takes a single value) – The function or callable to be called. This function will be passed True if a connection is established, False if a disconnect occurs. Notice that when a connection is established, the client has not yet logged in or completed any recovery steps. The application should not issue commands on the client until recovery is completed. |
---|
Add a message handler to the Client to handle messages and the requested acks sent in response to the given command_id.
Parameters: |
|
---|
A legacy method name for allocate_message().
Creates a new Message appropriate for this client.
This function should be called rarely, since it does allocate a handful of small objects.
Returns: | A new Message instance. |
---|
- Places a bookmark subscription with AMPS. Starts replay at the most
- recent message reported by the bookmark parameter.
Parameters: |
|
---|---|
Raises: | SubscriptionAlreadyExistsException, BadFilterException, BadRegexTopicException, TimedOutException, DisconnectedException. |
Disconnect from the AMPS server.
Connects to the AMPS instance through the provided URI.
- The URI is a string with the format:
- transport://userId:password@host:port/protocol where:
transport – The network transport used for the connection.
- userId – If authentication is enabled, this is the unique user ID
used to authenticate the connection.
- password – If authentication is enabled, this is the password used
to authenticate the connection.
- host – The hostname or IP address of the host where AMPS is
installed.
port – The port to connect to the AMPS instance.
protocol – The protocol used by this connection.
Note
Authentication is optional, if the system is using the default authentication with AMPS which allows all users in without regard for their userId or password, then the userId:password@ string can be omitted from the connect URI.
Parameters: | uri (str) – The :class`URI` used to connect to AMPS. |
---|---|
Raises: | ConnectionException |
convert_version_to_number(version)Converts the provided version string to a number using 2 digits for each dot. A value such as 4.0 will become 4000000 while 3.8.1.7 will return 3080107.
Parameters: | version (str) – The version string to convert. |
---|---|
Returns: | The numeric value for the version string. |
This is a legacy method name for delta_publish().
Deprecated since version 3.2.0.0: Use delta_publish() instead.
A legacy method name for delta_subscribe().
Deprecated since version 3.2.0.0: Use delta_subscribe() instead.
Delta publish a message to an AMPS topic.
Parameters: |
|
---|---|
Raises: |
Places a delta subscription with AMPS.
Parameters: |
|
---|---|
Returns: | The command identifier assigned to this command. |
Raises: | SubscriptionAlreadyExistsException, BadFilterException, BadRegexTopicException, TimedOutException, DisconnectedException |
Disconnects and closes any active connections.
Executes a Command on self.
Param: | An AMPS.Command to execute. |
---|---|
Returns: | A MessageStream to iterate over. |
Execute the provided command and process responses on the client receive thread using the provided handler.
This method creates a Message based on the provided Command, sends the Message to AMPS, and invokes the provided handler to process messages returned in response to the command. Rather than providing messages on the calling thread, the AMPS Python client runs the handler directly on the client receive thread.
When the provided handler is not None, this function blocks until AMPS acknowledges that the command has been processed. The results of the command after that acknowledgement are provided to the handler.
Parameters: |
|
---|---|
Returns: | The command ID assigned to the executed command. |
Another name for publish_flush().
A legacy method name for get_name().
Returns the current batch size used for batching message queue ACK messages.
Returns the current time (milliseconds) before queued ack messages are sent.
Returns True if auto-acknowledgement of message queue messages is enabled.
Returns the current maximum depth for new MessageStreams, 0 is no maximum.
Returns the message handler object set with set_duplicate_message_handler.
Returns the exception listener callable set on self, or None.
Returns the data used to correlate the logon of this Client to the server.
Returns: | logon correlation data |
---|
Returns the name of the Client object.
Returns: | name |
---|
Returns True if automatc retry of a command to AMPS after a reconnect is enabled.
Returns the connected server’s version as a numeric value.
Returns: | The version converted to a number: server version 3.8.1.7 would be 3080107 |
---|
Returns the connected server’s version as a VersionInfo.
Returns: | The version in a VersionInfo |
---|
Returns the count of unpersisted publishes.
Returns: | count of unpersisted publishes. |
---|
Returns the URI string passed into the Client during the connect() invocation.
Returns: | uri |
---|
Logs into AMPS with the parameters provided in the connect() method.
Parameters: |
|
---|---|
Returns: | The command identifier. |
Raises: |
Returns the name of the Client object.
Returns: | name |
---|
Publish a mesage to an AMPS topic. If the client was created with a persistent store on construction, then the client will store before forwarding the message to AMPS. In this store-and-forward case, the persistent store will notify the user, when requested via callback, of the successful persistence of the record within AMPS. If a DisconnectException occurs, the message is still stored in the publish store.
Parameters: |
|
---|---|
Raises: | DisconnectedException The client is not connected; the program needs to call connect() |
Ensures that pending AMPS messages are sent and have been processed by the AMPS server. When the client is connected to a server that implements the flush command, the client issues that command and waits for an acknowledgement. For older versions of AMPS, the client sends a publish to a dummy topic. This method blocks until messages have been processed or until the timeout expires, 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 publish_flush 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: | timeout (int) – The maximum time to wait for the flush to be acknowledged in milliseconds, or 0 for no maximum. |
---|
Removes a listener function previously supplied to add_connection_state_listener.
Remove a message handler from the Client.
Parameters: | command_id (str) – The command_id for the handler to remove. |
---|
Parameters: |
|
---|---|
Returns: | The command identifier assigned to this command, or None if one is not assigned. |
Deprecated since version 3.2.0.0: Use set_disconnect_handler() instead.
Deprecated since version 3.2.0.0: Use set_exception_listener() instead.
Deprecated since version 3.2.0.0: Use set_name() instead.
Deprecated since version 3.2.0.0: Use set_disconnect_handler() instead.
Deprecated since version 3.2.0.0: Use set_last_chance_message_handler() instead.
Sets the batch size used for batching message queue ACK messages.
:param batch_size The number of ACK messages to batch before sending.
Sets the time before queued ack messages are sent.
:param timeout The ack message send timeout, in milliseconds. 0 indicates no timeout.
Enables or disables auto-acknowledgement of message queue messages.
:param enabled True to enable auto-acknowledgement of message queue messages.
Sets a bookmark store on self.
Parameters: | bookmarkStore – an MMapBookmarkStore or MemoryBookmarkStore instance, or a custom object that implements the required bookmark store methods. |
---|
- Sets a default maximum depth for all new MessageStream objects
- that are returned from synchronous API calls such as execute().
:param depth The new depth to use. A depth of 0 means no max and is the default. :type depth: int.
- Sets the DisconnectHandler used by the Client. In
- the event that the Client is unintentionally disconnected from AMPS, the invoke method from the ClientDisconnectHandler will be invoked.
Parameters: | client_disconnect_handler – The disconnect handler. |
---|
- Sets the MessageHandler instance used for messages that arrive from AMPS
- that are deemed to be duplicates of previous messages, according to the local bookmark store.
Parameters: | message_handler (MessageHandler) – The message handler to invoke for duplicates messages. |
---|
- Sets the exception listener instance used for communicating
- absorbed exceptions.
Parameters: | exception_listener (Exception) – The exception listener instance to invoke for exceptions. |
---|
Sets a failed write handler on self.
Parameters: | failedWriteHandler – a callable object to be invoked when AMPS indicates that a published message is not written. This could be because a duplicate message already exists in the transaction log, this client is not entitled to publish to the topic, the message failed to parse, or other similar reasons. Parameters to this callable are an AMPS message when the client has a message saved in the publish store, and a string that contains the reason the publish failed. |
---|
For example, you might implement a function like:
def PrintFailedWrites(message, reason):
output = "Uh-oh, something went wrong writing to AMPS. (%s) " % reason
if (message != None):
output += "Topic: %s, Data snippet: %s..." % \
(message.get_topic(), message.get_data()[0:20])
print output
Client sends a heartbeat message to an AMPS instance, the AMPS instance will send back an acknowledgment message. From this point forward the Client and AMPS instance will each monitor that the other is still active. AMPS sends heartbeat messages to the client at the specified interval. If the Client does not receive a heartbeat message within the time interval specified in :timeout_seconds, then the Client will assume that the connection has ended, close the connection and invoke the DisconnectHandler. Likewise, if the server sends a heartbeat and does not receive a response within the timeout, the server will consider the client to be nonresponsive and close the connection.
Heartbeats are processed in the client receive thread. If you use asynchronous message processing, your message handler must process messages within the timeout interval, or risk being disconnected by the server.
Parameters: |
|
---|
Sets the MessageHandler instance called when no other incoming message handler matches.
Parameters: | message_handler (MessageHandler) – The message handler to invoke when no other incoming message handler matches. |
---|
Sets the data used to correlate the logon of this Client in the server.
Parameters: | logonCorrelationData – The base64 data string to send with the logon. |
---|
A legacy method name for set_name().
Sets a publish store on self.
Parameters: | publishStore – an PublishStore or MemoryPublishStore instance. |
---|
- Enables or disables automatic retry of a command to AMPS after a
- reconnect. This behavior is enabled by default. NOTE: Clients using a publish store will have all publish messages sent, regardless of this setting. Also, Clients with a subscription manager, including all HAClients, will have all subscribe calls placed.
:param enabled False to disable automatic retry of commands to AMPS. :type enabled: Boolean.
Sets a function to be called when this client sends or receives data.
Deprecated since version 4.0.0.0: Use set_last_chance_message_handler() instead.
Executes a SOW query. There are two ways to use this method. First, you can provide a topic, filter, and options for the subscription. In this case, the method returns a message stream that you can iterate over. For example:
c = Client("test_client")
try:
c.connect("tcp://127.0.0.1:9004/fix")
cid = c.logon(timeout=0)
for aMessage in c.sow("MySowTopic"):
print aMessage.get_data()
finally:
c.close()
Second, you can provide a message handler. In this case, the method creates a background thread and calls the message handler with each message received from AMPS, including the group_begin and group_end messages that indicate the beginning and end of the SOW query.
Parameters: |
|
---|---|
Returns: | If a message handler is provided, returns the command identifier assigned to this command. If no message handler is present, returns a MessageStream containing the results of the command. |
Raises: | BadFilterException, BadRegexTopicException, TimedOutException, DisconnectedException |
Deprecated since version 3.2.0.0: Use sow_and_delta_subscribe() instead.
Deprecated since version 3.2.0.0: Use sow_and_subscribe() instead.
Deprecated since version 3.2.0.0: Use sow_delete() instead.
Executes a SOW query and places a delta subscription.
Parameters: |
|
---|---|
Returns: | The command identifier assigned to this command. |
Raises: | SubscriptionAlreadyExistsException, BadFilterException, BadRegexTopicException, TimedOutException, DisconnectedException |
Executes a SOW query and places a subscription.
Parameters: |
|
---|---|
Returns: | The command identifier assigned to this command. |
Raises: | SubscriptionAlreadyExistsException, BadFilterException, BadRegexTopicException, TimedOutException, DisconnectedException |
Executes a SOW delete with a filter.
There are two ways to use this method. When no message handler is provided, the method returns a Message that will receive the results of the delete command.
When a message handler is provided, this method submits the SOW delete on a background thread and calls the message handler with the results of the delete.
For example, to delete all messages that match a filter:
...
ackMessage = client.sow_delete("sow_topic","/status = 'obsolete'")
print "%s: %s" % (ackMessage.get_ack_type(), ackMessage.get_status())
...
Parameters: |
|
---|---|
Returns: | The command identifier assigned to this command. |
Raises: | BadFilterException, BadRegexTopicException, TimedOutException, DisconnectedException |
Delete a message from a SOW, using data supplied to locate a SOW entry with matching keys.
There are two ways to use this method. When no message handler is provided, the method returns a Message that will receive the results of the delete command.
When a message handler is provided, this method submits the SOW delete on a background thread and calls the message handler with the results of the delete.
For example, to efficiently delete a message that your program has received from AMPS:
...
topic= aMessage.get_topic()
data = aMessage.get_data()
ackMessage = client.sow_delete_by_data(topic,data)
print "%s: %s" % (ackMessage.get_ack_type(), ackMessage.get_status())
...
In addition to deleting a message from AMPS, this method allows deletion of a message whose keys match one that is already stored, for example:
...
data = orders[orderId]
ackMessage = client.sow_delete_by_data('orders', data)
del orders[orderId]
...
Parameters: |
|
---|---|
Returns: | The command identifier assigned to this command. |
Executes a SOW delete with sow keys.
There are two ways to use this method. When no message handler is provided, the method returns a Message that will receive the results of the delete command.
When a message handler is provided, this method submits the SOW delete on a background thread and calls the message handler with the results of the delete.
Parameters: |
|
---|---|
Returns: | The command identifier assigned to this command. |
Used to start a timer on an AMPS Server for the client.
Used to stop a timer on an AMPS Server previously started for the client. :param handler: The handler to be invoked with the timer response.
Places a subscription with AMPS.
Parameters: |
|
---|---|
Returns: | The command identifier assigned to this command. |
Raises: | SubscriptionAlreadyExistsException, BadFilterException, BadRegexTopicException, TimedOutException, DisconnectedException |
Remove a subscription from AMPS.
Parameters: | sub_id – The subscription id to remove. |
---|
Bases: AMPS.ConnectionException
deprecated - use NameInUseException
Bases: object
A class to specify an AMPS command to run.
Adds an ack type to self.
Resets this command with a new Command type and re-initializes all other fields.
Param: | A string indicating the AMPS command. |
---|
Sets the batch size of self.
Sets the bookmark of self.
Sets the command id of self.
Sets the correlation ID of self.
Sets the data of self.
Sets the expiration of self.
Sets the filter of self.
Sets the options of self.
Sets the order by clause of self.
The sow key for a command is used to publish to a SOW topic on the publisher is responsible for determining and setting the key.
Param: | The sow key to set. |
---|
The sow keys for a command are a comma-separated list of the keys that AMPS assigns to SOW messges. The SOW key for a message is available through the Message.get_sow_key() method on a message.
Param: | The sow keys to set. |
---|
Sets the subscription id of self.
Sets the timeout of self.
Sets the top N field of self.
Sets the topic of self.
Bases: AMPS.AMPSException
deprecated - use CommandException
Bases: AMPS.CommandError
The CommandException is raised when a Command is used in an improper or unrecognized manner.
Bases: AMPS.CommandException
deprecated - legacy exception
Bases: AMPS.CommandException
deprecated - use CommandException
Bases: object
AMPS CompositeMessageBuilder Object
Appends a message part to this object.
Clears this object. Does not resize or free internal buffer.
Returns the composite message’s data.
Bases: object
AMPS CompositeMessageParser Object
Returns the index’th composite message part, or None if index is invalid.
Returns the index’th composite message part as a python bytes object, or None if index is invalid.
Parse a composite message body or composite AMPS.Message. Returns the number of valid parts parsed.
Returns the number of message parts last parsed.
Bases: AMPS.AMPSException
deprecated - use ConnectionException
Bases: AMPS.ConnectionError
The ConnectionException is raised when the client is unable to connect to AMPS.
Bases: AMPS.ConnectionException
deprecated - use ConnectionRefusedException
Bases: AMPS.ConnectionRefused
The ConnectionRefusedException is raised when the connection to AMPS is refused due to a socket error.
Bases: AMPS.LocalStorageError
deprecated - legacy exception
Bases: object
AMPS Authenticator Object
Authenticates self to an external system.
Parameters: |
|
---|---|
Returns: | The new password to be sent to the server in the logon request. |
Called when authentication is completed, with the username and password returned by the server in the final acknowledgement for the logon sequence.
Parameters: |
|
---|
Called when the server indicates a retry is necessary to complete authentication.
Parameters: |
|
---|---|
Returns: | The new password or authentication token to be sent to the server. |
Bases: object
A simple ServerChooser that keeps a list of AMPS instances and Authenticators, and advances to the next one when failure occurs.
To use the DefaultServerChooser, you add the URIs for the server to choose from, then set the server for the HAClient as shown below:
client = AMPS.HAClient("showchooser")
chooser = AMPS.DefaultServerChooser()
chooser.add("tcp://server:9005/nvfix")
chooser.add("tcp://server-two:9005/nvfix")
client.set_server_chooser(chooser)
client.connect_and_logon()
You can add any number of URIs to the DefaultServerChooser.
Adds a URI to this server chooser.
Parameters: | uri (str) – The URI of an AMPS instance that may be chosen. |
---|
Adds a list of URIs to this server chooser.
Parameters: | uris – The list of URIs of AMPS instances that may be chosen. |
---|
Called by HAClient to retrieve an Authenticator to use for authentication with the current server.
Returns: | The current Authenticator. |
---|
Called by the HAClient to retrieve the current URI to connect to.
Returns: | A URI to connect to, or None if no server should be connected to. |
---|
Provides additional detail to be included in an exception thrown by when the AMPS instance(s) are not available. Called by the HAClient when creating an exception.
Returns: | A string with information about the connection that failed and the reason for the failure. When no further information is available, returns an empty string. |
---|
Invoked to advance to the next server.
Bases: AMPS.ConnectionException
deprecated - use DisconnectedException
Bases: AMPS.Disconnected
The DisconnectedException is raised when an operation is requested by the client, but either a connection has yet to be established or the client was disconnected.
Bases: object
ExponentialDelayStrategy is an implementation that exponentially backs off when reconnecting to the same server, with a maximum time to retry before it gives up entirely.
Constructor parameters:
Parameters: |
|
---|
Returns the time that the client should delay before connecting to the given server URI.
Reset the state of this reconnect delay. AMPS calls this method when a connection is established.
Bases: object
AMPS FIXBuilder Object
Appends tag=value to self. :param tag: The numeric tag to use. :type tag: int :param value: The value for the given tag. :type value: str :param offset: Optional. The offset into value at which the value actually starts. :type offset: int :param length: Optional. The length of the actual value within value. Only valid and required if offset is also provided :type tag: int
Called to get the string FIX message.
Returns: | The FIX message as a string. |
---|
Called to clear the state of the FIXBuilder to create a new FIX message
Bases: object
Convenience class for easily processing FIX strings. Constructor arguments:
Parameters: | separator – The delimiter to expect between FIX fields. Defaults to chr(1) if no delimiter is provided. |
---|
Parse the provided FIX message and return a map that contains the fields in the message.
Parameters: | message – The FIX message to parse. |
---|
Bases: object
FixedDelayStrategy is a reconnect delay strategy implementation that waits a fixed amount of time before retrying a connection.
Constructor parameters:
Parameters: |
|
---|
Returns the time that the client should delay before connecting to the given server URI.
Reset the state of this reconnect delay. AMPS calls this method when a connection is established.
Bases: AMPS.Client
AMPS HAClient Object used for highly-available client connections. Derives from Client. Constructor arguments:
Parameters: |
|
---|
Connects and logs on using the ServerChooser you’ve supplied via set_server_chooser(). Will continue attempting to connect and logon to each URI returned by the ServerChooser until the connection succeeds or the ServerChooser returns an empty URI.
Connects and logs on using the ServerChooser you’ve supplied via set_server_chooser(). Will continue attempting to connect and logon to each URI returned by the ServerChooser until the connection succeeds or the ServerChooser returns an empty URI.
Discards a message from the local bookmark store.
Parameters: | message (AMPS.Message) – an AMPS.Message instance that was received from a bookmark subscription. |
---|
Gets self’s logon options string and returns it.
Gets the most recent bookmark from the local bookmark store for the given subscription id.
Parameters: | sub_id (string) – The subscription id for which to retrieve the most recent bookmark. |
---|
Returns the reconnect delay strategy object used to control delay behavior when connecting and reconnecting to servers.
Returns: | The reconnect delay strategy object. |
---|
Gets selfs server chooser and returns it.
Not used in the HAClient; call connect_and_logon() to connect and log on to AMPS once a server chooser is set.
Prunes the local bookmark store. If it’s file-based, it will remove unnecessary entries from the file.
Parameters: | tmp_file_name (string) – Optional file name to use for temporary storage during prune operation. |
---|
Sets a logon options on self.
Parameters: | options (string) – an options string to be passed to the server during logon, such as ack_conflation=100us. |
---|
Sets the delay in milliseconds used when reconnecting, after a disconnect occurs. Calling this method creates and installs a new FixedDelayStrategy in this client. Default value is 200 (0.2 seconds). :param reconnectDelay: The number of milliseconds to wait before reconnecting, after a disconnect occurs.
Sets the reconnect delay strategy object used to control delay behavior when connecting and reconnecting to servers.
Parameters: | strategy – The reconnect delay strategy object to use when connecting and reconnecting to AMPS instances. The object must have the following two methods defined:
|
---|
Sets a server chooser on self.
Parameters: | serverChooser (ServerChooser) – a ServerChooser instance, such as a DefaultServerChooser. |
---|
Sets the timeout in milliseconds used when sending a logon command to the server. Default value is 10000 (10 seconds). :param timeout: The number of milliseconds to wait for a server response to logon. 0 indicates no timeout.
Bases: object
AMPS HybridPublishStore Object
Returns the number of messages published which have not been ACK’ed by the server.
Sets the object to call when the store needs to resize.
Bases: AMPS.MessageTypeException
deprecated - use MessageTypeException
Bases: AMPS.CommandException
deprecated - use InvalidTopicException
Bases: AMPS.InvalidTopicError
The InvalidTopicException is raised when a query is performed against a topic that does not exist.
Bases: AMPS.TransportException
deprecated - use InvalidTransportOptionsException
Bases: AMPS.InvalidTransportOptions
InvalidTransportOptionsException is raised when a URI string contains invalid options for a given transport.
Bases: AMPS.InvalidUriFormat
InvalidUriException is raised when the format of the URI is invalid.
Bases: AMPS.ConnectionException
deprecated - use InvalidUriException
Bases: AMPS.AMPSException
deprecated - legacy exception
Bases: object
AMPS MMapBookmarkStore Object
Stores bookmarks in a local file. Construct with the filename to use or recover from.
Log a discard-bookmark entry to the persisted log.
Log a message as discarded from the store.
Returns the most recent bookmark from the log that ought to be used for (re-)subscriptions.
Called to find the oldest bookmark sequence in the store.
Called for each arriving message to determine if the application has already seen this bookmark and should not be reprocessed. Returns True if the bookmark is in the log and should not be re-processed, False otherwise.
Log a bookmark to the log and return the corresponding sequence number.
Flag the subscription as being on an older server without persisted acks. No persisted acks will be sent for any bookmarks.
Mark all bookmarks up to the provided one as replicated to all replication destinations for the given subscription.
persisted(subid, bookmark_index)
Mark all bookmarks up to the provided index as replicated to all replication destinations for the given subscription.
Used to trim the size of a store’s storage. Implemented for file based stores to remove items no longer necessary to create the current state.
Called to purge the contents of this store. Removes any tracking history associated with publishers and received messages, and may delete or truncate on-disk representations as well.
Called to purge the contents of this store for a given subscription id. Removes any tracking history associated with publishers and received messages, and may delete or truncate on-disk representations as well.
Sets the object to call when the store needs to resize.
Internally used to set the server version so the store knows how to deal with persisted acks and calls to get_most_recent().
Bases: object
AMPS MemoryBookmarkStore Object
Log a discard-bookmark entry to the persisted log.
Log a message as discarded from the store.
Returns the most recent bookmark from the log that ought to be used for (re-)subscriptions.
Called to find the oldest bookmark sequence in the store.
Called for each arriving message to determine if the application has already seen this bookmark and should not be reprocessed. Returns True if the bookmark is in the log and should not be re-processed, False otherwise.
Log a bookmark to the log and return the corresponding sequence number.
Flag the subscription as being on an older server without persisted acks. No persisted acks will be sent for any bookmarks.
Mark all bookmarks up to the provided one as replicated to all replication destinations for the given subscription.
persisted(subid, bookmark_index)
Mark all bookmarks up to the provided index as replicated to all replication destinations for the given subscription.
Called to purge the contents of this store. Removes any tracking history associated with publishers and received messages, and may delete or truncate on-disk representations as well.
Called to purge the contents of this store for a given subscription id. Removes any tracking history associated with publishers and received messages, and may delete or truncate on-disk representations as well.
Sets the object to call when the store needs to resize.
Internally used to set the server version so the store knows how to deal with persisted acks and calls to get_most_recent().
Bases: object
AMPS PublishStore Object
Returns the number of messages published which have not been ACK’ed by the server.
Sets the object to call when the store needs to resize.
Bases: object
AMPS Message Object
Bases: object
AMPS Options Object used to build options strings for commands.
Returns: | The value of ack_type on this message. |
---|
Returns: | The value of batch_size on this message. |
---|
Returns: | The value of bookmark on this message. |
---|
Returns: | The value of client_name on this message. |
---|
Returns: | The value of command on this message. |
---|
Returns: | The value of command_id on this message. |
---|
Returns: | The value of correlation_id on this message. |
---|
Returns: | The value of data on this message. |
---|
Returns: | The value of expiration on this message. |
---|
Returns: | The value of filter on this message. |
---|
Returns: | The value of group_seq_no on this message. |
---|
Returns: | The value of lease_period on this message. |
---|
Returns: | The value of matches on this message. |
---|
Returns: | The value of message_size on this message. |
---|
Returns: | The value of message_type on this message. |
---|
Returns: | The value of options on this message. |
---|
Returns: | The value of password on this message. |
---|
Returns: | The value of query_id on this message. |
---|
Returns: | The value of reason on this message. |
---|
Returns: | The value of records_inserted on this message. |
---|
Returns: | The value of records_returned on this message. |
---|
Returns: | The value of records_updated on this message. |
---|
Returns: | The value of sequence on this message. |
---|
Returns: | The value of sow_deleted on this message. |
---|
Returns: | The value of sow_key on this message. |
---|
Returns: | The value of sow_keys on this message. |
---|
Returns: | The value of status on this message. |
---|
Returns: | The value of sub_id on this message. |
---|
Returns: | The value of sub_ids on this message. |
---|
Returns: | The value of timestamp on this message. |
---|
Returns: | The value of top_n on this message. |
---|
Returns: | The value of topic on this message. |
---|
Returns: | The value of topic_matches on this message. |
---|
Returns: | The value of user_id on this message. |
---|
Returns: | The value of ack_type on this message. |
---|
Returns: | The value of batch_size on this message. |
---|
Returns: | The value of bookmark on this message. |
---|
Gets the bookmark sequence number of this message.
Returns: | The value of client_name on this message. |
---|
Returns: | The value of command on this message. |
---|
Returns: | The value of command_id on this message. |
---|
Returns: | The value of correlation_id on this message. |
---|
Returns: | The value of data on this message. |
---|
Returns: | the data of this message as a python bytes object |
---|
Returns: | The value of expiration on this message. |
---|
Returns: | The value of filter on this message. |
---|
Returns: | The value of group_seq_no on this message. |
---|
Returns: | The value of lease_period on this message. |
---|
Returns: | The value of matches on this message. |
---|
Returns: | The value of message_size on this message. |
---|
Returns: | The value of message_type on this message. |
---|
Returns: | The value of options on this message. |
---|
Returns: | The value of password on this message. |
---|
Returns: | The value of query_id on this message. |
---|
Returns: | The value of reason on this message. |
---|
Returns: | The value of records_inserted on this message. |
---|
Returns: | The value of records_returned on this message. |
---|
Returns: | The value of records_updated on this message. |
---|
Returns: | The value of sequence on this message. |
---|
Returns: | The value of sow_deleted on this message. |
---|
Returns: | The value of sow_key on this message. |
---|
Returns: | The value of sow_keys on this message. |
---|
Returns: | The value of status on this message. |
---|
Returns: | The value of sub_id on this message. |
---|
Returns: | The value of sub_ids on this message. |
---|
Returns: | The value of timestamp on this message. |
---|
Returns: | The value of top_n on this message. |
---|
Returns: | The value of topic on this message. |
---|
Returns: | The value of topic_matches on this message. |
---|
Returns: | The value of user_id on this message. |
---|
Resets the contents of this message.
Sets the value of ack_type on this message.
Parameters: | value – The new value for ack_type. |
---|
Sets the value of batch_size on this message.
Parameters: | value – The new value for batch_size. |
---|
Sets the value of bookmark on this message.
Parameters: | value – The new value for bookmark. |
---|
Sets the value of client_name on this message.
Parameters: | value – The new value for client_name. |
---|
Sets the value of command on this message.
Parameters: | value – The new value for command. |
---|
Sets the value of command_id on this message.
Parameters: | value – The new value for command_id. |
---|
Sets the value of correlation_id on this message.
Parameters: | value – The new value for correlation_id. |
---|
Sets the value of data on this message.
Parameters: | value – The new value for data. |
---|
Sets the value of expiration on this message.
Parameters: | value – The new value for expiration. |
---|
Sets the value of filter on this message.
Parameters: | value – The new value for filter. |
---|
Sets the value of group_seq_no on this message.
Parameters: | value – The new value for group_seq_no. |
---|
Sets the value of lease_period on this message.
Parameters: | value – The new value for lease_period. |
---|
Sets the value of matches on this message.
Parameters: | value – The new value for matches. |
---|
Sets the value of message_size on this message.
Parameters: | value – The new value for message_size. |
---|
Sets the value of message_type on this message.
Parameters: | value – The new value for message_type. |
---|
Sets the value of options on this message.
Parameters: | value – The new value for options. |
---|
Sets the value of password on this message.
Parameters: | value – The new value for password. |
---|
Sets the value of query_id on this message.
Parameters: | value – The new value for query_id. |
---|
Sets the value of reason on this message.
Parameters: | value – The new value for reason. |
---|
Sets the value of records_inserted on this message.
Parameters: | value – The new value for records_inserted. |
---|
Sets the value of records_returned on this message.
Parameters: | value – The new value for records_returned. |
---|
Sets the value of records_updated on this message.
Parameters: | value – The new value for records_updated. |
---|
Sets the value of sequence on this message.
Parameters: | value – The new value for sequence. |
---|
Sets the value of sow_deleted on this message.
Parameters: | value – The new value for sow_deleted. |
---|
Sets the value of sow_key on this message.
Parameters: | value – The new value for sow_key. |
---|
Sets the value of sow_keys on this message.
Parameters: | value – The new value for sow_keys. |
---|
Sets the value of status on this message.
Parameters: | value – The new value for status. |
---|
Sets the value of sub_id on this message.
Parameters: | value – The new value for sub_id. |
---|
Sets the value of sub_ids on this message.
Parameters: | value – The new value for sub_ids. |
---|
Sets the value of timestamp on this message.
Parameters: | value – The new value for timestamp. |
---|
Sets the value of top_n on this message.
Parameters: | value – The new value for top_n. |
---|
Sets the value of topic on this message.
Parameters: | value – The new value for topic. |
---|
Sets the value of topic_matches on this message.
Parameters: | value – The new value for topic_matches. |
---|
Sets the value of user_id on this message.
Parameters: | value – The new value for user_id. |
---|
Sets the value of ack_type on this message.
Parameters: | value – The new value for ack_type. |
---|
Sets the value of batch_size on this message.
Parameters: | value – The new value for batch_size. |
---|
Sets the value of bookmark on this message.
Parameters: | value – The new value for bookmark. |
---|
Sets the value of client_name on this message.
Parameters: | value – The new value for client_name. |
---|
Sets the value of command on this message.
Parameters: | value – The new value for command. |
---|
Sets the value of command_id on this message.
Parameters: | value – The new value for command_id. |
---|
Sets the value of correlation_id on this message.
Parameters: | value – The new value for correlation_id. |
---|
Sets the value of data on this message.
Parameters: | value – The new value for data. |
---|
Sets the value of expiration on this message.
Parameters: | value – The new value for expiration. |
---|
Sets the value of filter on this message.
Parameters: | value – The new value for filter. |
---|
Sets the value of group_seq_no on this message.
Parameters: | value – The new value for group_seq_no. |
---|
Sets the value of lease_period on this message.
Parameters: | value – The new value for lease_period. |
---|
Sets the value of matches on this message.
Parameters: | value – The new value for matches. |
---|
Sets the value of message_size on this message.
Parameters: | value – The new value for message_size. |
---|
Sets the value of message_type on this message.
Parameters: | value – The new value for message_type. |
---|
Sets the value of options on this message.
Parameters: | value – The new value for options. |
---|
Sets the value of password on this message.
Parameters: | value – The new value for password. |
---|
Sets the value of query_id on this message.
Parameters: | value – The new value for query_id. |
---|
Sets the value of reason on this message.
Parameters: | value – The new value for reason. |
---|
Sets the value of records_inserted on this message.
Parameters: | value – The new value for records_inserted. |
---|
Sets the value of records_returned on this message.
Parameters: | value – The new value for records_returned. |
---|
Sets the value of records_updated on this message.
Parameters: | value – The new value for records_updated. |
---|
Sets the value of sequence on this message.
Parameters: | value – The new value for sequence. |
---|
Sets the value of sow_deleted on this message.
Parameters: | value – The new value for sow_deleted. |
---|
Sets the value of sow_key on this message.
Parameters: | value – The new value for sow_key. |
---|
Sets the value of sow_keys on this message.
Parameters: | value – The new value for sow_keys. |
---|
Sets the value of status on this message.
Parameters: | value – The new value for status. |
---|
Sets the value of sub_id on this message.
Parameters: | value – The new value for sub_id. |
---|
Sets the value of sub_ids on this message.
Parameters: | value – The new value for sub_ids. |
---|
Sets the value of timestamp on this message.
Parameters: | value – The new value for timestamp. |
---|
Sets the value of top_n on this message.
Parameters: | value – The new value for top_n. |
---|
Sets the value of topic on this message.
Parameters: | value – The new value for topic. |
---|
Sets the value of topic_matches on this message.
Parameters: | value – The new value for topic_matches. |
---|
Sets the value of user_id on this message.
Parameters: | value – The new value for user_id. |
---|
Bases: object
A message handler used to create an in-thread iterator interface over the Messages that are returned from a command.
Closes this message stream.
Enables message conflation by SOW key.
Gets the current depth of this message stream.
Gets the maximum depth allowed for this message stream.
Sets the maximum depth allowed for this message stream.
x.next() -> the next value, or raise StopIteration
Sets the timeout on this message stream.
If no message is received in this timeout, None is returned to the caller of next(), and the stream remains open.
Bases: AMPS.ConnectionException
deprecated - use MessageTypeException
Bases: AMPS.MessageTypeError
MessageTypeException is raised when the message type requested by the client is unsupported.
Bases: AMPS.MessageTypeException
deprecated - use MessageTypeException
Bases: object
Convenience class for easily creating NVFIX strings. Constructor arguments:
Parameters: | delimiter – The delimiter to use between NFVIX fields. Defaults to \x01 if no delimiter is provided. |
---|
Appends tag=value to self.
Parameters: |
|
---|
Called to get the string NVFIX message.
Returns: | The NVFIX message as a string. |
---|
Called to clear the state of the NVFIXBuilder to create a new NVFIX message
Bases: object
Convenience class for easily processing NVFIX strings. Constructor arguments:
Parameters: | separator – The delimiter to expect between NFVIX fields. Defaults to \x01 if no delimiter is provided. |
---|
Parse the provided NVFIX message and return a map that contains the fields in the message.
Parameters: | message – The NVFIX message to parse. |
---|
Bases: AMPS.ClientNameInUse
NameInUseException is raised when a client attempts to connect and uses the same client name as a currently connected client.
Bases: AMPS.ConnectionException
deprecated - use NotEntitledException
Bases: AMPS.NotEntitledError
NotEntitledException is raised when an authenticated client attempts to access a resource to which the user has not been granted proper entitlements.
Bases: object
AMPS PublishStore Object
Stores published records in a file while awaiting an ACK from the server. Construct with the name of the file to use for record storage.
Returns the number of messages published which have not been ACK’ed by the server.
Sets the object to call when the store needs to resize.
Sets if the PublishStore should truncate the file to initial capacity when it closes if it is empty.
Bases: object
AMPS Reason Object
Bases: AMPS.ConnectionException
deprecated - use RetryOperationException
Bases: AMPS.RetryOperation
RetryOperationException is raised when sending of a message has failed two consecutive attempts. Any send which receives this can assume that the message was not delivered to AMPS.
Bases: object
AMPS Store Object
Bases: AMPS.ConnectionException
deprecated - use StreamException
Bases: AMPS.StreamError
StreamException is raised when an incoming message is improperly formatted.
Bases: AMPS.CommandException
The SubidInUseException is raised when a subscription is place with the same subscription id.
Bases: AMPS.CommandException
deprecated - use SubscriptionAlreadyExistsException
Bases: AMPS.SubscriptionAlreadyExists
The SubscriptionAlreadyExistsException is raised when a subscription is place which matches a subscription that already exists.
Bases: AMPS.ConnectionException
deprecated - use TimedOutException
Bases: AMPS.TimedOut
The TimedOutException is raised when an operation times out.
Bases: AMPS.ConnectionException
deprecated - use TransportException
Bases: AMPS.TransportError
TransportException is raised when an AMPS Client transport has an error.
Bases: AMPS.TransportException
deprecated - use TransportException
Bases: AMPS.ConnectionException
TransportTypeException is raised when an unknown or invalid transport is attempted.
Bases: AMPS.CommandException
deprecated - use UnknownException
Bases: AMPS.UnknownError
The UnknownException is raised when the AMPS Python Client is in an unrecoverable state.
Bases: object
AMPS VersionInfo Object
Returns the version as number with 2 digits for major version, 2 digits for minor version, 2 digits for maintennce version and 2 digits for patch version. Any values greater than 99 are represented as 99.
Returns the version as number with 4 digits for major version, 4 digits for minor version, 5 digits for maintennce version and 5 digits for patch version.
Returns the version string.
Sets the string version to represent.
Initializes SSL support in the AMPS module.
Parameters: | dllpath – The path to the OpenSSL DLL or shared library to use for SSL functionality. |
---|