Perspectium DataSync Agents support an “exclusive consumer” mode that provides a Highly Available Agent solution while maintaining the order of messages in a queue. This active-passive Highly Available approach will exclusively allow only one DataSync Agent to actively read messages from a queue. Other DataSync Agents that passively try to connect to the queue will only be given access to the queue if another DataSync Agent is no longer connected.

DataSync Agents use the queue in the message connection and locks that queue for exclusive use. If multiple tasks are made using the same message connection, only one subscriber task will be created and used. When running another DataSync Agent, a warning will be logged in the perspectium.log file indicating that the queue is in exclusive use and that consumer wait time will be increased (default is to increase to 30 seconds). Once the first running DataSync Agent is stopped or fails, the backup DataSync Agent will start consuming messages when the queue becomes available and the consumer wait time will be reset.

(info) NOTE: The Highly Available Agent is only available when your DataSync Agent is set to connect to the Perspectium Mesh via the AMQP/AMQPS protocol (HTTP/HTTPS is not supported).


Prerequisites


(warning) First, you will need to set up one of the Perspectium DataSync Agents.

(warning) You should also stop running your DataSync Agent before making any Agent configuration changes.

Procedure

To configure your DataSync Agent to run as a Highly Available Agent, follow these steps:


Access your agent.xml configuration file

Navigate to the directory where you saved your agent.xml file when installing your DataSync Agent.

Add the exclusive attribute to <message_connection>

Open your agent.xml file in a text editing application and locate the <message_connection> tag, which should be nested within <task>. To the <message_connection> tag, add an attribute named exclusive and set its value to true.

Add a <consumer_sleep_time> tag (optional)

Within the <task> tag, you can optionally nest a tag named <consumer_sleep_time> whose value will indicate the number of milliseconds that a passively connecting DataSync Agent should wait before attempting to connect again following a failed connection.

Save your agent.xml

Save the changes you've made to your agent.xml and close the file. An example agent.xml configuration for a Highly Available DataSync Agent is shown below:

<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
    <config>
     <agent>

        <max_reads_per_connect>2000</max_reads_per_connect>
       	<polling_interval>15</polling_interval>

        <subscribe>
            <task>
                <task_name>ticket_table_replication</task_name>
                <polling_interval>30</polling_interval>

                <handler>com.perspectium.replicator.sql.SQLSubscriber</handler>
                <decryption_key>The cow jumped over the moon</decryption_key>

                <message_connection queue="psp.out.replicator.example" password="encrypted:iTOCp4deP7rJNgFkf2AEMA==" user="exampleuser"  use_basic_consume="true" exclusive="true" >amqp://acme.perspectium.net</message_connection>
                <instance_connection user="example.user" password="examplepassword">https://myinstance.service-now.com</instance_connection>
                <consumer_sleep_time>50000</consumer_sleep_time>
                <database_type>mysql</database_type>
                <database_server>localhost</database_server>
                <database_port>3306</database_port>
                <database_user>root</database_user>
                <database_password>encrypt:mypassword</database_password>
                <database_parms/>
                <database>mydatabase</database>
                <skip_database_creation/>
            </task>
      </subscribe>

   </agent>
  </config>

Run your Highly Available DataSync Agent

After configuring your agent.xml file to support your Highly Available DataSync Agent, start running your DataSync Agent again.