Export (0) Print
Expand All

TransSynchronizationAgent Class

 

Applies To: SQL Server 2016 Preview

Provides the functionality of the Replication Distribution Agent.

Namespace:   Microsoft.SqlServer.Replication
Assembly:  Microsoft.SqlServer.Replication (in Microsoft.SqlServer.Replication.dll)

System.Object
  System.MarshalByRefObject
    Microsoft.SqlServer.Replication.TransSynchronizationAgent

[ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)]
[GuidAttribute("adeda98a-bdfc-4029-b6fb-991d6b468395")]
[ComVisibleAttribute(true)]
[PermissionSetAttribute(SecurityAction.Demand, Name = "FullTrust")]
public class TransSynchronizationAgent : MarshalByRefObject, 
	IDisposable

NameDescription
System_CAPS_pubmethodTransSynchronizationAgent()

Creates an instance of the TransSynchronizationAgent class.

NameDescription
System_CAPS_pubpropertyAltSnapshotFolder

Gets or sets the alternate snapshot folder for the subscription.

System_CAPS_pubpropertyComErrorCollection

Gets a collection of errors that are generated by the replication agent.

System_CAPS_pubpropertyDistributor

Gets or sets the name of the instance of Microsoft SQL Server that is acting as the distributor for the subscription.

System_CAPS_pubpropertyDistributorAddress

Gets or sets the network address that is used to connect to the distributor when the DistributorNetwork property is specified.

System_CAPS_pubpropertyDistributorEncryptedPassword

This API supports the product infrastructure and is not intended to be used directly from your code. Gets or sets the encrypted password that is used when connecting to the distributor by using SQL Server Authentication.

System_CAPS_pubpropertyDistributorLogin

Gets or sets the login name that is used when connecting to the distributor by using SQL Server Authentication.

System_CAPS_pubpropertyDistributorNetwork

Gets or sets the client Net-Library that is used when connecting to the distributor.

System_CAPS_pubpropertyDistributorPassword

Gets or sets the password that is used when connecting to the Distributor by using SQL Server Authentication.

System_CAPS_pubpropertyDistributorSecurityMode

Gets or sets the security mode that is used when connecting to the distributor.

System_CAPS_pubpropertyDtsPackageFileName

Gets or sets the name and path of a Microsoft SQL Server 2000 Data Transformation Services (DTS) package that is used to transform command rowsets before they are applied to a Subscriber.

System_CAPS_pubpropertyDtsPackagePassword

Gets or sets the owner password that used to access the Microsoft SQL Server 2000 Data Transformation Services (DTS) package specified by the DtsPackageFileName property.

System_CAPS_pubpropertyFileTransferType

Gets or sets how the initial snapshot files are transferred to the Subscriber.

System_CAPS_pubpropertyHostName

This API supports the product infrastructure and is not intended to be used directly from your code. Gets or sets the host name used.

System_CAPS_pubpropertyLastUpdatedTime

Gets the timestamp of the last time that replication agent synchronized the subscription.

System_CAPS_pubpropertyLoginTimeout

Gets or sets the maximum number of seconds to wait for connections to be established.

System_CAPS_pubpropertyMaxDeliveredTransactions

Gets or sets the maximum number of transactions that are applied to the Subscriber during a single agent execution.

System_CAPS_pubpropertyOutput

Gets or sets the file name and path of the agent output file.

System_CAPS_pubpropertyOutputVerboseLevel

Gets or sets the amount of information that is logged by the Distribution Agent in the agent output file.

System_CAPS_pubpropertyProfileName

Gets or sets the name of the profile that is used by the agent.

System_CAPS_pubpropertyPublication

Gets or sets the name of the publication.

System_CAPS_pubpropertyPublisher

Gets or sets the name of the instance of Microsoft SQL Server that is the Publisher for the subscription.

System_CAPS_pubpropertyPublisherDatabase

Gets or sets the name of the publication database.

System_CAPS_pubpropertyQueryTimeout

Gets or sets the number of seconds that are allowed for internal queries to complete.

System_CAPS_pubpropertySecureDistributorEncryptedPassword

This API supports the product infrastructure and is not intended to be used directly from your code. Gets or sets the secure encrypted password for the distributor.

System_CAPS_pubpropertySecureSubscriberEncryptedPassword

This API supports the product infrastructure and is not intended to be used directly from your code. Gets or sets the secure encrypted password for the subscriber.

System_CAPS_pubpropertySkipErrors

Gets or sets a colon-separated list of the error numbers that are to be skipped by this agent.

System_CAPS_pubpropertySubscriber

Gets or sets the name of the instance of Microsoft SQL Server that is the subscriber.

System_CAPS_pubpropertySubscriberDatabase

Gets or sets the name of the subscription database.

System_CAPS_pubpropertySubscriberDatabasePath

This API supports the product infrastructure and is not intended to be used directly from your code. Get or sets the database path for the subscriber.

System_CAPS_pubpropertySubscriberDataSourceType

Gets or sets the type of data source that is used as the subscriber.

System_CAPS_pubpropertySubscriberEncryptedPassword

This API supports the product infrastructure and is not intended to be used directly from your code. Gets or sets the encrypted password for the subscriber.

System_CAPS_pubpropertySubscriberLogin

Gets or sets the login name that is used when connecting to the subscriber by using SQL Server Authentication.

System_CAPS_pubpropertySubscriberPassword

Gets or sets the password that is used when connecting to the subscriber by using SQL Server Authentication.

System_CAPS_pubpropertySubscriberSecurityMode

Gets or sets the security mode that is used when connecting to the publisher.

System_CAPS_pubpropertySubscriptionType

Gets or sets whether the subscription is a push or pull subscription.

System_CAPS_pubpropertyUndeliveredCommands

This API supports the product infrastructure and is not intended to be used directly from your code. Gets the number of undelivered commands.

System_CAPS_pubpropertyUndeliveredTransactions

This API supports the product infrastructure and is not intended to be used directly from your code. Gets the number of undelivered transactions.

System_CAPS_pubpropertyUseInProcLoader

Gets or sets a value that indicates whether to use the BULK INSERT command when applying snapshot files at the subscriber.

System_CAPS_pubpropertyWorkingDirectory

Gets or sets the working directory from which snapshot files are accessed when File Transfer Protocol (FTP) is used.

NameDescription
System_CAPS_pubmethodAbort()

This API supports the product infrastructure and is not intended to be used directly from your code. Aborts the TransSynchronizationAgent operation.

System_CAPS_pubmethodCreateObjRef(Type)

(Inherited from MarshalByRefObject.)

System_CAPS_pubmethodDispose()

This API supports the product infrastructure and is not intended to be used directly from your code. Releases all resources used by the current instance of the TransSynchronizationAgent class.

System_CAPS_protmethodDispose(Boolean)

Releases all resources used by the TransSynchronizationAgent class.

System_CAPS_pubmethodEquals(Object)

(Inherited from Object.)

System_CAPS_protmethodFinalize()

This API supports the product infrastructure and is not intended to be used directly from your code. Finalizes the TransSynchronizationAgent.(Overrides Object.Finalize().)

System_CAPS_pubmethodGetHashCode()

(Inherited from Object.)

System_CAPS_pubmethodGetLifetimeService()

(Inherited from MarshalByRefObject.)

System_CAPS_pubmethodGetType()

(Inherited from Object.)

System_CAPS_pubmethodInitializeLifetimeService()

(Inherited from MarshalByRefObject.)

System_CAPS_pubmethodIsSnapshotRequired()

Connects to the Distributor and the Subscriber to determine whether a new snapshot will be applied during the next agent synchronization.

System_CAPS_protmethodMemberwiseClone()

(Inherited from Object.)

System_CAPS_protmethodMemberwiseClone(Boolean)

(Inherited from MarshalByRefObject.)

System_CAPS_pubmethodSynchronize()

Starts the Distribution Agent to synchronize the subscription.

System_CAPS_pubmethodToString()

(Inherited from Object.)

NameDescription
System_CAPS_pubeventComStatus

This API supports the product infrastructure and is not intended to be used directly from your code. Occurs when the Distribution Agent returns synchronization Com status information.

System_CAPS_pubeventStatus

Occurs when the Distribution Agent returns synchronization status information.

The TransSynchronizationAgent class does not support multithreaded apartments. You can specify a single-threaded apartment by declaring the [STAThread] attribute on the method that is the main entry point for the application. This is the default for Microsoft Windows-based applications that are created by using Microsoft Visual Studio.

The TransSynchronizationAgent class supports the ability to programmatically synchronize subscriptions to transactional or snapshot publications.

Legacy Code Example

In the following example, the Synchronize method is called on the instance of the TransSynchronizationAgent class that is accessed from the SynchronizationAgent property to synchronize the push subscription.

			// Define the server, publication, and database names.
			string subscriberName = subscriberInstance;
			string publisherName = publisherInstance;
			string publicationName = "AdvWorksProductTran";
			string subscriptionDbName = "AdventureWorks2012Replica";
			string publicationDbName = "AdventureWorks2012";

			// Create a connection to the Publisher.
			ServerConnection conn = new ServerConnection(publisherName);

			TransSubscription subscription;

			try
			{
				// Connect to the Publisher.
				conn.Connect();

				// Define the push subscription.
				subscription = new TransSubscription();
				subscription.ConnectionContext = conn;
				subscription.DatabaseName = publicationDbName;
				subscription.PublicationName = publicationName;
				subscription.SubscriptionDBName = subscriptionDbName;
				subscription.SubscriberName = subscriberName;

				// If the push subscription exists, start the synchronization.
				if (subscription.LoadProperties())
				{
					// Check that we have enough metadata to start the agent.
					if (subscription.SubscriberSecurity != null)
					{
						// Synchronously start the Distribution Agent for the subscription.
						subscription.SynchronizationAgent.Synchronize();
					}
					else
					{
						throw new ApplicationException("There is insufficent metadata to " +
							"synchronize the subscription. Recreate the subscription with " +
							"the agent job or supply the required agent properties at run time.");
					}
				}
				else
				{
					// Do something here if the push subscription does not exist.
					throw new ApplicationException(String.Format(
						"The subscription to '{0}' does not exist on {1}",
						publicationName, subscriberName));
				}
			}
			catch (Exception ex)
			{
				// Implement appropriate error handling here.
				throw new ApplicationException("The subscription could not be synchronized.", ex);
			}
			finally
			{
				conn.Disconnect();
			}
Return to top
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2015 Microsoft