Partilhar via


How to: Measure Latency and Validate Connections for Transactional Replication (RMO Programming)

For transactional replication, it is important to be able to verify that servers are connected and to measure latency. You measure latency by using tracer tokens. Latency is the time that elapses for changes made at the Publisher to be propagated to Subscribers. For more information, see Measuring Latency and Validating Connections for Transactional Replication. This information can be obtained programmatically by using Replication Management Objects (RMO).

To post a tracer token to a transactional publication

  1. Create a connection to the Publisher by using the ServerConnection class.

  2. Create an instance of the TransPublication class.

  3. Set the Name and DatabaseName properties for the publication, and set the ConnectionContext property to the connection created in step 1.

  4. Call the LoadProperties method to get the properties of the object. If this method returns false, either the publication properties in step 3 were defined incorrectly or the publication does not exist.

  5. Call the PostTracerToken method. This method inserts a tracer token into the publication's transaction log.

To determine latency and validate connections for a transactional publication

  1. Create a connection to the Distributor by using the ServerConnection class.

  2. Create an instance of the PublicationMonitor class.

  3. Set the Name, DistributionDBName, PublisherName, and PublicationDBName properties, and set the ConnectionContext property to the connection created in step 1.

  4. Call the LoadProperties method to get the properties of the object. If this method returns false, either the publication monitor properties in step 3 were defined incorrectly or the publication does not exist.

  5. Call the EnumTracerTokens method. Cast the returned ArrayList object to an array of TracerToken objects.

  6. Call the EnumTracerTokenHistory method. Pass a value of TracerTokenID for a tracer token from step 5. This returns latency information for the selected tracer token as a DataSet object. If all tracer token information is returned, the connection between the Publisher and Distributor and the connection between the Distributor and the Subscriber both exist and the replication topology is functioning.

To remove tracer tokens

  1. Create a connection to the Distributor by using the ServerConnection class.

  2. Create an instance of the PublicationMonitor class.

  3. Set the Name, DistributionDBName, PublisherName, and PublicationDBName properties, and set the ConnectionContext property to the connection created in step 1.

  4. Call the LoadProperties method to get the properties of the object. If this method returns false, either the publication monitor properties in step 3 were defined incorrectly or the publication does not exist.

  5. Call the EnumTracerTokens method. Cast the returned ArrayList object to an array of TracerToken objects.

  6. Call the CleanUpTracerTokenHistory method. Pass one of the following values:

    • The TracerTokenID for a tracer token from step 5. This deletes information for a selected token.
    • A DateTime object. This deletes information for all tokens older than the specified date and time.

See Also

Tasks

How to: Measure Latency and Validate Connections for Transactional Replication (Replication Transact-SQL Programming)

Other Resources

How to: Measure Latency and Validate Connections for Transactional Replication (Replication Monitor)

Help and Information

Getting SQL Server 2005 Assistance