MergeSynchronizationAgent 클래스

정의

복제 병합 에이전트의 기능을 제공합니다.

public ref class MergeSynchronizationAgent : MarshalByRefObject, IDisposable, Microsoft::SqlServer::Replication::IMergeSynchronizationAgent
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)]
[System.Runtime.InteropServices.ComSourceInterfaces(typeof(Microsoft.SqlServer.Replication.IComStatusEvent))]
[System.Runtime.InteropServices.ComVisible(true)]
[System.Runtime.InteropServices.Guid("ee5ee47e-6d29-448f-b2d2-f8e632db336a")]
public class MergeSynchronizationAgent : MarshalByRefObject, IDisposable, Microsoft.SqlServer.Replication.IMergeSynchronizationAgent
[<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)>]
[<System.Runtime.InteropServices.ComSourceInterfaces(typeof(Microsoft.SqlServer.Replication.IComStatusEvent))>]
[<System.Runtime.InteropServices.ComVisible(true)>]
[<System.Runtime.InteropServices.Guid("ee5ee47e-6d29-448f-b2d2-f8e632db336a")>]
type MergeSynchronizationAgent = class
    inherit MarshalByRefObject
    interface IDisposable
    interface IMergeSynchronizationAgent
Public Class MergeSynchronizationAgent
Inherits MarshalByRefObject
Implements IDisposable, IMergeSynchronizationAgent
상속
MergeSynchronizationAgent
특성
구현

예제

다음 예제 Synchronize 에서는 푸시 구독을 동기화하기 위해 속성에서 액세스하는 클래스의 MergeSynchronizationAgent 인스턴스에서 SynchronizationAgent 메서드를 호출합니다.

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

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

MergeSubscription subscription;

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

    // Define the subscription.
    subscription = new MergeSubscription();
    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 Merge 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 = "AdvWorksSalesOrdersMerge"
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 MergeSubscription

Try
    ' Connect to the Publisher
    conn.Connect()

    ' Define the subscription.
    subscription = New MergeSubscription()
    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 Merge Agent for the subscription.
            ' Log agent messages to an output file.
            subscription.SynchronizationAgent.Output = "mergeagent.log"
            subscription.SynchronizationAgent.OutputVerboseLevel = 2
            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

다음 예제에서는 클래스의 인스턴스를 MergeSynchronizationAgent 사용하여 병합 구독을 동기화합니다. 끌어오기 구독은 값을 CreateSyncAgentByDefault사용하여 false 만들었으므로 추가 속성을 제공해야 합니다.

// Define the server, publication, and database names.
string subscriberName = subscriberInstance;
string publisherName = publisherInstance;
string distributorName = distributorInstance;
string publicationName = "AdvWorksSalesOrdersMerge";
string subscriptionDbName = "AdventureWorks2012Replica";
string publicationDbName = "AdventureWorks2012";
string hostname = @"adventure-works\garrett1";
string webSyncUrl = "https://" + publisherInstance + "/SalesOrders/replisapi.dll";

// Create a connection to the Subscriber.
ServerConnection conn = new ServerConnection(subscriberName);

MergePullSubscription subscription;
MergeSynchronizationAgent agent;

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

    // Define the pull subscription.
    subscription = new MergePullSubscription();
    subscription.ConnectionContext = conn;
    subscription.DatabaseName = subscriptionDbName;
    subscription.PublisherName = publisherName;
    subscription.PublicationDBName = publicationDbName;
    subscription.PublicationName = publicationName;

    // If the pull subscription exists, then start the synchronization.
    if (subscription.LoadProperties())
    {
        // Get the agent for the subscription.
        agent = subscription.SynchronizationAgent;

        // Check that we have enough metadata to start the agent.
        if (agent.PublisherSecurityMode == null)
        {
            // Set the required properties that could not be returned
            // from the MSsubscription_properties table. 
            agent.PublisherSecurityMode = SecurityMode.Integrated;
            agent.DistributorSecurityMode = SecurityMode.Integrated;
            agent.Distributor = publisherName;
            agent.HostName = hostname;

            // Set optional Web synchronization properties.
            agent.UseWebSynchronization = true;
            agent.InternetUrl = webSyncUrl;
            agent.InternetSecurityMode = SecurityMode.Standard;
            agent.InternetLogin = winLogin;
            agent.InternetPassword = winPassword;
        }
        // Enable agent output to the console.
        agent.OutputVerboseLevel = 1;
        agent.Output = "";

        // Synchronously start the Merge Agent for the subscription.
        agent.Synchronize();
    }
    else
    {
        // Do something here if the pull subscription does not exist.
        throw new ApplicationException(String.Format(
            "A 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. Verify that the subscription has " +
        "been defined correctly.", 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 = "AdvWorksSalesOrdersMerge"
Dim subscriptionDbName As String = "AdventureWorks2012Replica"
Dim publicationDbName As String = "AdventureWorks2012"
Dim hostname As String = "adventure-works\garrett1"
Dim webSyncUrl As String = "https://" + publisherInstance + "/SalesOrders/replisapi.dll"

' Create a connection to the Subscriber.
Dim conn As ServerConnection = New ServerConnection(subscriberName)

Dim subscription As MergePullSubscription
Dim agent As MergeSynchronizationAgent

Try
    ' Connect to the Subscriber.
    conn.Connect()

    ' Define the pull subscription.
    subscription = New MergePullSubscription()
    subscription.ConnectionContext = conn
    subscription.DatabaseName = subscriptionDbName
    subscription.PublisherName = publisherName
    subscription.PublicationDBName = publicationDbName
    subscription.PublicationName = publicationName

    ' If the pull subscription exists, then start the synchronization.
    If subscription.LoadProperties() Then
        ' Get the agent for the subscription.
        agent = subscription.SynchronizationAgent

        ' Check that we have enough metadata to start the agent.
        If agent.PublisherSecurityMode = Nothing Then
            ' Set the required properties that could not be returned
            ' from the MSsubscription_properties table. 
            agent.PublisherSecurityMode = SecurityMode.Integrated
            agent.Distributor = publisherInstance
            agent.DistributorSecurityMode = SecurityMode.Integrated
            agent.HostName = hostname

            ' Set optional Web synchronization properties.
            agent.UseWebSynchronization = True
            agent.InternetUrl = webSyncUrl
            agent.InternetSecurityMode = SecurityMode.Standard
            agent.InternetLogin = winLogin
            agent.InternetPassword = winPassword
        End If

        ' Enable agent logging to the console.
        agent.OutputVerboseLevel = 1
        agent.Output = ""

        ' Synchronously start the Merge Agent for the subscription.
        agent.Synchronize()
    Else
        ' Do something here if the pull subscription does not exist.
        Throw New ApplicationException(String.Format( _
         "A 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. Verify that the subscription has " + _
     "been defined correctly.", ex)
Finally
    conn.Disconnect()
End Try

설명

클래스는 MergeSynchronizationAgent 다음 복제 작업을 수행하는 기능을 지원합니다.

  • 구독을 동기화합니다.

  • 동기화 중에 업로드 단계, 다운로드 단계만 또는 두 단계 모두 실행할지 여부를 지정합니다.

  • 구독에 예상 데이터가 있는지 확인합니다.

  • 구독에 대한 초기 스냅샷을 적용할 수 있는 다른 스냅샷 폴더를 지정합니다.

생성자

MergeSynchronizationAgent()

MergeSynchronizationAgent 클래스의 인스턴스를 만듭니다.

속성

AlternateSynchronizationPartnerCollection

구독의 대체 동기화 파트너를 가져옵니다.

AltSnapshotFolder

구독의 대체 스냅샷 폴더를 가져오거나 설정합니다.

ComErrorCollection

복제 에이전트가 생성한 오류의 컬렉션을 가져옵니다.

Distributor

구독의 배포자 역할을 하는 Microsoft SQL Server 인스턴스의 이름을 가져오거나 설정합니다.

DistributorAddress

DistributorNetwork 속성이 지정된 경우 배포자에 연결하는 데 사용되는 네트워크 주소를 가져오거나 설정합니다.

DistributorEncryptedPassword

암호화된 배포자 암호를 가져오거나 설정합니다.

DistributorLogin

SQL Server 인증을 사용하여 배포자에 연결할 때 사용되는 로그인 이름을 가져오거나 설정합니다.

DistributorNetwork

배포자에 연결할 때 사용되는 클라이언트 Net-Library를 가져오거나 설정합니다.

DistributorPassword

SQL Server 인증을 사용하여 배포자에 연결할 때 사용되는 암호를 설정합니다.

DistributorSecurityMode

배포자에 연결할 때 사용되는 보안 모드를 가져오거나 설정합니다.

DownloadGenerationsPerBatch

게시자의 변경 내용을 구독자로 다운로드하는 동안 한 번의 일괄 처리에서 처리할 세대 수를 가져오거나 설정합니다. 세대는 아티클 단위의 논리적 변경 내용 그룹으로 정의됩니다.

DynamicSnapshotLocation

이 구독자의 분할된 스냅샷 위치를 가져오거나 설정합니다.

ExchangeType

동기화 중에 데이터가 교환되는 방법을 가져오거나 설정합니다.

FileTransferType

초기 스냅샷 파일이 구독자에 전송되는 방법을 가져오거나 설정합니다.

HostName

HOST_NAME 함수를 사용하는 매개 변수가 있는 필터를 평가할 때 병합 에이전트 사용하는 값을 가져오거나 설정합니다.

InputMessageFile

입력 메시지 파일을 가져오거나 설정합니다.

InternetLogin

인터넷 인증을 사용하여 게시자에 연결할 때 웹 동기화에서 사용되는 로그인 이름을 가져오거나 설정합니다.

InternetPassword

인터넷 인증을 사용하여 게시자에 연결할 때 웹 동기화에서 사용되는 InternetLogin 속성의 암호를 설정합니다.

InternetProxyLogin

인터넷 프록시 서버를 사용하여 웹 서버에 연결할 때 웹 동기화에서 사용되는 로그인 이름을 가져오거나 설정합니다.

InternetProxyPassword

인터넷 프록시 서버를 사용하여 웹 서버에 연결할 때 웹 동기화에서 사용되는 로그인의 암호를 설정합니다.

InternetProxyServer

웹 서버에 연결할 때 웹 동기화에서 사용되는 인터넷 프록시 서버의 이름을 가져오거나 설정합니다.

InternetSecurityMode

웹 동기화 중에 웹 서버에 연결할 때 사용되는 HTTP 인증 방법을 가져오거나 설정합니다.

InternetTimeout

웹 서버에 연결할 때 HTTP 제한 시간을 가져오거나 설정합니다.

InternetUrl

웹 동기화에 대해 구성된 웹 서비스의 URL을 가져오거나 설정합니다.

LastUpdatedTime

복제 에이전트가 마지막으로 구독을 동기화한 시간을 나타내는 타임스탬프를 가져옵니다.

LoginTimeout

연결이 설정될 때까지 대기하는 최대 시간(초)을 가져오거나 설정합니다.

MetadataRetentionCleanup

메타데이터를 정리할지 여부를 가져오거나 설정합니다.

Output

에이전트 출력 파일을 가져오거나 설정합니다.

OutputMessageFile

입력 메시지 파일을 가져오거나 설정합니다.

OutputVerboseLevel

에이전트 출력 파일에 기록된 정보의 세부 수준을 가져오거나 설정합니다.

ProfileName

에이전트가 사용하는 프로필의 이름을 가져오거나 설정합니다.

Publication

게시의 이름을 가져오거나 설정합니다.

Publisher

구독의 게시자인 Microsoft SQL Server 인스턴스의 이름을 가져오거나 설정합니다.

PublisherAddress

PublisherNetwork 속성이 지정된 경우 게시자에 연결하는 데 사용되는 네트워크 주소를 가져오거나 설정합니다.

PublisherChanges

마지막 동기화 중에 구독자에서 적용된 게시자 변경 내용의 총 수를 가져옵니다.

PublisherConflicts

마지막 동기화 중에 게시자에서 발생한 총 충돌 수를 가져옵니다.

PublisherDatabase

게시 데이터베이스의 이름을 가져오거나 설정합니다.

PublisherEncryptedPassword

암호화된 게시자 암호를 가져오거나 설정합니다.

PublisherFailoverPartner

게시 데이터베이스를 사용하여 데이터베이스 미러링 세션에 참여하는 SQL Server 장애 조치(failover) 파트너 인스턴스를 가져오거나 설정합니다.

PublisherLogin

SQL Server 인증을 사용하여 게시자에 연결할 때 사용되는 로그인 이름을 가져오거나 설정합니다.

PublisherNetwork

게시자에 연결할 때 사용되는 클라이언트 Net-Library를 가져오거나 설정합니다.

PublisherPassword

SQL Server 인증을 사용하여 게시자에 연결할 때 사용되는 암호를 설정합니다.

PublisherSecurityMode

게시자에 연결할 때 사용되는 보안 모드를 가져오거나 설정합니다.

QueryTimeout

내부 쿼리 완료에 허용되는 시간(초)을 가져오거나 설정합니다.

SecureDistributorEncryptedPassword

암호화된 배포자 보안 암호를 가져오거나 설정합니다.

SecurePublisherEncryptedPassword

암호화된 게시자 보안 암호를 가져오거나 설정합니다.

SecureSubscriberEncryptedPassword

암호화된 구독자 보안 암호를 가져오거나 설정합니다.

Subscriber

구독자인 Microsoft SQL Server 인스턴스의 이름을 가져오거나 설정합니다.

SubscriberChanges

마지막 동기화 중에 게시자에서 적용된 구독자 변경 내용의 총 수를 가져옵니다.

SubscriberConflicts

마지막 동기화 중에 게시자에서 발생한 총 충돌 수를 가져옵니다.

SubscriberDatabase

구독 데이터베이스의 이름을 가져오거나 설정합니다.

SubscriberDatabasePath

구독자 데이터베이스 경로를 가져오거나 설정합니다.

SubscriberDataSourceType

구독자로 사용되는 데이터 원본의 유형을 가져오거나 설정합니다.

SubscriberEncryptedPassword

암호화된 구독자 암호를 가져오거나 설정합니다.

SubscriberLogin

SQL Server 인증을 사용하여 구독자에 연결할 때 사용되는 로그인 이름을 가져오거나 설정합니다.

SubscriberPassword

SQL Server 인증을 사용하여 구독자에 연결할 때 사용되는 암호를 설정합니다.

SubscriberSecurityMode

구독자에 연결할 때 사용되는 보안 모드를 가져오거나 설정합니다.

SubscriptionType

구독이 밀어넣기 구독인지 아니면 끌어오기 구독인지를 가져오거나 설정합니다.

SyncToAlternate

대체 동기화 파트너와 동기화하는지 여부를 가져오거나 설정합니다.

UploadGenerationsPerBatch

구독자의 변경 내용을 게시자로 업로드하는 동안 한 번의 일괄 처리에서 처리할 세대 수를 가져오거나 설정합니다. 세대는 아티클 단위의 논리적 변경 내용 그룹으로 정의됩니다.

UseInteractiveResolver

조정하는 동안 대화형 해결 프로그램이 사용되는지 여부를 가져오거나 설정합니다.

UseWebSynchronization

웹 동기화가 사용되는지 여부를 가져오거나 설정합니다.

Validate

동기화가 끝날 때 구독자 데이터에 대한 유효성 검사가 수행되는지 여부를 가져오거나 설정합니다.

WorkingDirectory

FTP가 사용될 때 스냅샷 파일이 액세스되는 작업 디렉터리를 가져오거나 설정합니다.

메서드

Abort()

동기화를 중단합니다.

ClearAllTraceFlags()

동기화 에이전트에서 사용하는 모든 추적 플래그를 지웁니다.

ClearTraceFlag(Int32)

추적 플래그를 지웁니다.

Dispose()

MergeSynchronizationAgent에서 사용하는 관리되지 않는 리소스를 해제합니다.

Dispose(Boolean)

클래스에서 사용하는 MergeSynchronizationAgent 관리되지 않는 리소스를 해제하고 필요에 따라 관리되는 리소스를 해제합니다.

EnableTraceFlag(Int32)

플래그 추적을 사용하도록 설정합니다.

Finalize()

에이전트를 종료합니다.

IsSnapshotRequired()

게시자 또는 배포자와 구독자에 연결하여 새 스냅샷이 다음 에이전트 동기화 중에 적용될지 여부를 확인합니다.

ProcessMessagesAtPublisher()

게시자에서 메시지를 처리합니다.

ProcessMessagesAtSubscriber()

구독자에서 메시지를 처리합니다.

Synchronize()

병합 에이전트를 시작하여 구독을 동기화합니다.

이벤트

ComStatus

병합 에이전트가 동기화 Com 상태 정보를 반환하면 발생합니다.

Status

병합 에이전트가 동기화 상태 정보를 반환하면 발생합니다.

적용 대상

스레드 보안

이 형식의 모든 public static(Visual Basic의 경우 Shared) 멤버는 스레드로부터 안전합니다. 인스턴스 구성원은 스레드로부터의 안전성이 보장되지 않습니다.