Freigeben über


TransSynchronizationAgent-Klasse

Provides the functionality of the Replication Distribution Agent.

Vererbungshierarchie

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

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

Syntax

'Declaration
<ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)> _
<GuidAttribute("adeda98a-bdfc-4029-b6fb-991d6b468395")> _
<ComVisibleAttribute(True)> _
<PermissionSetAttribute(SecurityAction.Demand, Name := "FullTrust")> _
Public Class TransSynchronizationAgent _
    Inherits MarshalByRefObject _
    Implements IDisposable, ITransSynchronizationAgent
'Usage
Dim instance As TransSynchronizationAgent
[ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)]
[GuidAttribute("adeda98a-bdfc-4029-b6fb-991d6b468395")]
[ComVisibleAttribute(true)]
[PermissionSetAttribute(SecurityAction.Demand, Name = "FullTrust")]
public class TransSynchronizationAgent : MarshalByRefObject, 
    IDisposable, ITransSynchronizationAgent
[ClassInterfaceAttribute(ClassInterfaceType::AutoDispatch)]
[GuidAttribute(L"adeda98a-bdfc-4029-b6fb-991d6b468395")]
[ComVisibleAttribute(true)]
[PermissionSetAttribute(SecurityAction::Demand, Name = L"FullTrust")]
public ref class TransSynchronizationAgent : public MarshalByRefObject, 
    IDisposable, ITransSynchronizationAgent
[<ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)>]
[<GuidAttribute("adeda98a-bdfc-4029-b6fb-991d6b468395")>]
[<ComVisibleAttribute(true)>]
[<PermissionSetAttribute(SecurityAction.Demand, Name = "FullTrust")>]
type TransSynchronizationAgent =  
    class 
        inherit MarshalByRefObject 
        interface IDisposable 
        interface ITransSynchronizationAgent 
    end
public class TransSynchronizationAgent extends MarshalByRefObject implements IDisposable, ITransSynchronizationAgent

Der TransSynchronizationAgent-Typ macht folgende Elemente verfügbar.

Konstruktoren

  Name Beschreibung
Öffentliche Methode TransSynchronizationAgent Creates an instance of the TransSynchronizationAgent class.

Zum Anfang

Eigenschaften

  Name Beschreibung
Öffentliche Eigenschaft AltSnapshotFolder Gets or sets the alternate snapshot folder for the subscription.
Öffentliche Eigenschaft ComErrorCollection Gets a collection of errors that are generated by the replication agent.
Öffentliche Eigenschaft Distributor Gets or sets the name of the instance of Microsoft SQL Server that is acting as the distributor for the subscription.
Öffentliche Eigenschaft DistributorAddress Gets or sets the network address that is used to connect to the distributor when the DistributorNetwork property is specified.
Öffentliche Eigenschaft DistributorEncryptedPassword Infrastruktur Gets or sets the encrypted password that is used when connecting to the distributor by using SQL Server Authentication.
Öffentliche Eigenschaft DistributorLogin Gets or sets the login name that is used when connecting to the distributor by using SQL Server Authentication.
Öffentliche Eigenschaft DistributorNetwork Gets or sets the client Net-Library that is used when connecting to the distributor.
Öffentliche Eigenschaft DistributorPassword Gets or sets the password that is used when connecting to the Distributor by using SQL Server Authentication.
Öffentliche Eigenschaft DistributorSecurityMode Gets or sets the security mode that is used when connecting to the distributor.
Öffentliche Eigenschaft DtsPackageFileName 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.
Öffentliche Eigenschaft DtsPackagePassword 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.
Öffentliche Eigenschaft FileTransferType Gets or sets how the initial snapshot files are transferred to the Subscriber.
Öffentliche Eigenschaft HostName Infrastruktur Gets or sets the host name used.
Öffentliche Eigenschaft LastUpdatedTime Gets the timestamp of the last time that replication agent synchronized the subscription.
Öffentliche Eigenschaft LoginTimeout Gets or sets the maximum number of seconds to wait for connections to be established.
Öffentliche Eigenschaft MaxDeliveredTransactions Gets or sets the maximum number of transactions that are applied to the Subscriber during a single agent execution.
Öffentliche Eigenschaft Output Gets or sets the file name and path of the agent output file.
Öffentliche Eigenschaft OutputVerboseLevel Gets or sets the amount of information that is logged by the Distribution Agent in the agent output file.
Öffentliche Eigenschaft ProfileName Gets or sets the name of the profile that is used by the agent.
Öffentliche Eigenschaft Publication Gets or sets the name of the publication.
Öffentliche Eigenschaft Publisher Gets or sets the name of the instance of Microsoft SQL Server that is the Publisher for the subscription.
Öffentliche Eigenschaft PublisherDatabase Gets or sets the name of the publication database.
Öffentliche Eigenschaft QueryTimeout Gets or sets the number of seconds that are allowed for internal queries to complete.
Öffentliche Eigenschaft SecureDistributorEncryptedPassword Infrastruktur Gets or sets the secure encrypted password for the distributor.
Öffentliche Eigenschaft SecureSubscriberEncryptedPassword Infrastruktur Gets or sets the secure encrypted password for the subscriber.
Öffentliche Eigenschaft SkipErrors Gets or sets a colon-separated list of the error numbers that are to be skipped by this agent.
Öffentliche Eigenschaft Subscriber Gets or sets the name of the instance of Microsoft SQL Server that is the subscriber.
Öffentliche Eigenschaft SubscriberDatabase Gets or sets the name of the subscription database.
Öffentliche Eigenschaft SubscriberDatabasePath Infrastruktur Get or sets the database path for the subscriber.
Öffentliche Eigenschaft SubscriberDataSourceType Gets or sets the type of data source that is used as the subscriber.
Öffentliche Eigenschaft SubscriberEncryptedPassword Infrastruktur Gets or sets the encrypted password for the subscriber.
Öffentliche Eigenschaft SubscriberLogin Gets or sets the login name that is used when connecting to the subscriber by using SQL Server Authentication.
Öffentliche Eigenschaft SubscriberPassword Gets or sets the password that is used when connecting to the subscriber by using SQL Server Authentication.
Öffentliche Eigenschaft SubscriberSecurityMode Gets or sets the security mode that is used when connecting to the publisher.
Öffentliche Eigenschaft SubscriptionType Gets or sets whether the subscription is a push or pull subscription.
Öffentliche Eigenschaft UndeliveredCommands Infrastruktur Gets the number of undelivered commands.
Öffentliche Eigenschaft UndeliveredTransactions Infrastruktur Gets the number of undelivered transactions.
Öffentliche Eigenschaft UseInProcLoader Gets or sets a value that indicates whether to use the BULK INSERT command when applying snapshot files at the subscriber.
Öffentliche Eigenschaft WorkingDirectory Gets or sets the working directory from which snapshot files are accessed when File Transfer Protocol (FTP) is used.

Zum Anfang

Methoden

  Name Beschreibung
Öffentliche Methode Abort Infrastruktur Aborts the TransSynchronizationAgent operation.
Öffentliche Methode CreateObjRef Sicherheitskritisch (Geerbt von MarshalByRefObject.)
Öffentliche Methode Dispose() Infrastruktur Releases all resources used by the current instance of the TransSynchronizationAgent class.
Geschützte Methode Dispose(Boolean) Releases all resources used by the TransSynchronizationAgent class.
Öffentliche Methode Equals (Geerbt von Object.)
Geschützte Methode Finalize Infrastruktur Finalizes the TransSynchronizationAgent. (Überschreibt Object.Finalize().)
Öffentliche Methode GetHashCode (Geerbt von Object.)
Öffentliche Methode GetLifetimeService Sicherheitskritisch (Geerbt von MarshalByRefObject.)
Öffentliche Methode GetType (Geerbt von Object.)
Öffentliche Methode InitializeLifetimeService Sicherheitskritisch (Geerbt von MarshalByRefObject.)
Öffentliche Methode IsSnapshotRequired Connects to the Distributor and the Subscriber to determine whether a new snapshot will be applied during the next agent synchronization.
Geschützte Methode MemberwiseClone() (Geerbt von Object.)
Geschützte Methode MemberwiseClone(Boolean) (Geerbt von MarshalByRefObject.)
Öffentliche Methode Synchronize Starts the Distribution Agent to synchronize the subscription.
Öffentliche Methode ToString (Geerbt von Object.)

Zum Anfang

Ereignisse

  Name Beschreibung
Öffentliches Ereignis ComStatus Infrastruktur Occurs when the Distribution Agent returns synchronization Com status information.
Öffentliches Ereignis Status Occurs when the Distribution Agent returns synchronization status information.

Zum Anfang

Hinweise

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

Beispiele

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();
            }
' Define the server, publication, and database names.
Dim subscriberName As String = subscriberInstance
Dim publisherName As String = publisherInstance
Dim publicationName As String = "AdvWorksProductTran"
Dim subscriptionDbName As String = "AdventureWorks2012Replica"
Dim publicationDbName As String = "AdventureWorks2012"

' Create a connection to the Publisher.
Dim conn As ServerConnection = New ServerConnection(publisherName)

Dim subscription As TransSubscription

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() Then
        ' Check that we have enough metadata to start the agent.
        If Not subscription.SubscriberSecurity Is Nothing Then

            ' 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.")
        End If
    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))
    End If
Catch ex As Exception
    ' Implement appropriate error handling here.
    Throw New ApplicationException("The subscription could not be synchronized.", ex)
Finally
    conn.Disconnect()
End Try

Threadsicherheit

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.

Siehe auch

Verweis

Microsoft.SqlServer.Replication-Namespace

Andere Ressourcen

Vorgehensweise: Synchronisieren eines Pullabonnements (RMO-Programmierung)

Vorgehensweise: Synchronisieren eines Pushabonnements (RMO-Programmierung)

Replikationsverteilungs-Agent