TransSubscription.SynchronizationAgent 속성

정의

구독을 동기화하는 데 사용할 수 있는 TransSynchronizationAgent 클래스의 인스턴스를 가져옵니다.

public:
 property Microsoft::SqlServer::Replication::TransSynchronizationAgent ^ SynchronizationAgent { Microsoft::SqlServer::Replication::TransSynchronizationAgent ^ get(); };
public Microsoft.SqlServer.Replication.TransSynchronizationAgent SynchronizationAgent { get; }
member this.SynchronizationAgent : Microsoft.SqlServer.Replication.TransSynchronizationAgent
Public ReadOnly Property SynchronizationAgent As TransSynchronizationAgent

속성 값

TransSynchronizationAgent

TransSynchronizationAgent 개체입니다.

예제

// 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

설명

반환 된 Synchronize 개체에 대해 메서드를 호출 TransSynchronizationAgent 하 여 구독을 동기화 합니다.

CommitPropertyChanges를 검색 하기 전에를 호출 하 여 구독을 동기화 하기 전에 서버에 대 한 모든 속성 변경 내용을 저장 해야 합니다 SynchronizationAgent .

에 대해 값을 사용 하 여 구독을 만드는 경우 false CreateSyncAgentByDefault 구독에 대 한 배포 에이전트 작업이 생성 되지 않습니다. 반환 된 개체를 사용 하 여 구독을 동기화 하기 전에 추가 속성을 지정 해야 할 수도 있습니다 TransSynchronizationAgent .

SynchronizationAgent속성은 sysadmin 게시자에서 고정 서버 역할의 멤버, db_owner 게시 데이터베이스에 대 한 고정 데이터베이스 역할의 멤버 또는 구독이 속한 게시에 대 한 PAL (게시 액세스 목록)의 멤버 에서만 검색할 수 있습니다.

검색 SynchronizationAgentSp_helpsubscription (transact-sql)을 실행 하는 것과 같습니다.

적용 대상