MergeSynchronizationAgent 클래스

Provides the functionality of the Replication Merge Agent.

System.Object
  System.MarshalByRefObject
    Microsoft.SqlServer.Replication.MergeSynchronizationAgent

네임스페이스:  Microsoft.SqlServer.Replication
어셈블리:  Microsoft.SqlServer.Replication(Microsoft.SqlServer.Replication.dll)

[ComVisibleAttribute(true)]
[GuidAttribute("ee5ee47e-6d29-448f-b2d2-f8e632db336a")]
[ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)]
[PermissionSetAttribute(SecurityAction.Demand, Name = "FullTrust")]
public class MergeSynchronizationAgent : MarshalByRefObject, 
	IDisposable, IMergeSynchronizationAgent

MergeSynchronizationAgent 유형에서 다음 멤버를 표시합니다.

  이름설명
공용 메서드MergeSynchronizationAgentCreates an instance of the MergeSynchronizationAgent class.
맨 위로 이동

  이름설명
공용 속성AlternateSynchronizationPartnerCollectionGets the alternate synchronization partners for a subscription.
공용 속성AltSnapshotFolderGets or sets the alternate snapshot folder for the subscription.
공용 속성ComErrorCollectionGets a collection of errors generated by the replication agent.
공용 속성DistributorGets or sets the name of the instance of Microsoft SQL Server that is acting as the Distributor for the subscription.
공용 속성DistributorAddressGets or sets the network address that is used to connect to the Distributor when the DistributorNetwork property is specified.
공용 속성DistributorEncryptedPassword인프라입니다. Gets or sets the distributor encrypted password.
공용 속성DistributorLoginGets or sets the login name that is used when connecting to the Distributor using SQL Server Authentication.
공용 속성DistributorNetworkGets or sets the client Net-Library that is used when connecting to the Distributor.
공용 속성DistributorPasswordSets the password that is used when connecting to the Distributor using SQL Server Authentication.
공용 속성DistributorSecurityModeGets or sets the security mode used when connecting to the Distributor.
공용 속성DownloadGenerationsPerBatchGets or sets the number of generations to be processed in a single batch while downloading changes from the Publisher to the Subscriber. A generation is defined as a logical group of changes per article.
공용 속성DynamicSnapshotLocationGets or sets the location of the partitioned snapshot for this Subscriber.
공용 속성ExchangeTypeGets or sets how data is exchanged during synchronization.
공용 속성FileTransferTypeGets or sets how the initial snapshot files are transferred to the Subscriber.
공용 속성HostNameGets or sets the value used by the Merge Agent when it evaluates a parameterized filter that uses the HOST_NAME function.
공용 속성InputMessageFile인프라입니다. Gets or sets the input message file.
공용 속성InternetLoginGets or sets the login name that is used with Web synchronization when connecting to the Publisher by using Internet authentication.
공용 속성InternetPasswordSets the password for the InternetLogin property that is used with Web synchronization when connecting to the Publisher by using Internet authentication.
공용 속성InternetProxyLoginGets or sets the login name that is used with Web synchronization when connecting to the Web server by using an Internet proxy server.
공용 속성InternetProxyPasswordSets the password for the login that is used with Web synchronization when connecting to the Web server by using an Internet proxy server.
공용 속성InternetProxyServerGets or sets the name of the Internet proxy server that is used with Web synchronization when connecting to the Web server.
공용 속성InternetSecurityModeGets or sets the HTTP authentication method that is used when connecting to the Web server during Web synchronization.
공용 속성InternetTimeoutGets or sets the HTTP time-out when connecting to the Web server.
공용 속성InternetUrlGets or sets the URL of the Web service that is configured for Web synchronization.
공용 속성LastUpdatedTimeGets the timestamp of the last time that replication agent synchronized the subscription.
공용 속성LoginTimeoutGets or sets the maximum number of seconds to wait for connections to be established.
공용 속성MetadataRetentionCleanupGet or sets whether to clean up metadata.
공용 속성OutputGets or sets the agent output file.
공용 속성OutputMessageFile인프라입니다. Gets or sets the input message file.
공용 속성OutputVerboseLevelGets or sets the level of detail of information that is written to the agent output file.
공용 속성ProfileNameGets or sets the name of the profile that is used by the agent.
공용 속성PublicationGets or sets the name of the publication.
공용 속성PublisherGets or sets the name of the instance of Microsoft SQL Server that is the Publisher for the subscription.
공용 속성PublisherAddressGets or sets the network address that is used to connect to the Publisher when the PublisherNetwork property is specified.
공용 속성PublisherChangesGets the total number of Publisher changes that were applied at the Subscriber during the last synchronization.
공용 속성PublisherConflictsGets the total number of conflicts that occurred at the Publisher during the last synchronization.
공용 속성PublisherDatabaseGets or sets the name of the publication database.
공용 속성PublisherEncryptedPassword인프라입니다. Gets or sets the publisher encrypted password.
공용 속성PublisherFailoverPartnerGets or sets the failover partner instance of SQL Server that is participating in a database mirroring session with the publication database.
공용 속성PublisherLoginGets or sets the login name that is used when connecting to the Publisher by using SQL Server Authentication.
공용 속성PublisherNetworkGets or sets the client Net-Library that is used when connecting to the Publisher.
공용 속성PublisherPasswordSets the password that is used when connecting to the Publisher by using SQL Server Authentication.
공용 속성PublisherSecurityModeGets or sets the security mode that is used when connecting to the Publisher.
공용 속성QueryTimeoutGets or sets the number of seconds that are allowed for internal queries to finish.
공용 속성SecureDistributorEncryptedPassword인프라입니다. Gets or sets the secure distributor encrypted password.
공용 속성SecurePublisherEncryptedPassword인프라입니다. Gets or sets the secure publisher encrypted password.
공용 속성SecureSubscriberEncryptedPassword인프라입니다. Gets or sets the secure subscriber encrypted password.
공용 속성SubscriberGets or sets the name of the instance of Microsoft SQL Server that is the Subscriber.
공용 속성SubscriberChangesGets the total number of Subscriber changes that were applied at the Publisher during the last synchronization.
공용 속성SubscriberConflictsGets the total number of conflicts that occurred at the Publisher during the last synchronization.
공용 속성SubscriberDatabaseGets or sets the name of the subscription database.
공용 속성SubscriberDatabasePath인프라입니다. Gets or sets the subscriber database path.
공용 속성SubscriberDataSourceTypeGets or sets the type of data source that is used as the Subscriber.
공용 속성SubscriberEncryptedPassword인프라입니다. Gets or sets the subscriber encrypted password.
공용 속성SubscriberLoginGets or sets the login name used that is when connecting to the Subscriber by using SQL Server Authentication.
공용 속성SubscriberPasswordSets the password that is used when connecting to the Subscriber by using SQL Server Authentication.
공용 속성SubscriberSecurityModeGets or sets the security mode used when connecting to the Subscriber.
공용 속성SubscriptionTypeGets or sets whether the subscription is a push or pull subscription.
공용 속성SyncToAlternateGets or sets whether the synchronization is to an alternate synchronization partner.
공용 속성UploadGenerationsPerBatchGets or sets the number of generations to be processed in a single batch while uploading changes from the Subscriber to the Publisher. A generation is defined as a logical group of changes per article.
공용 속성UseInteractiveResolverGets or sets whether the interactive resolver is used during reconciliation.
공용 속성UseWebSynchronizationGets or sets whether Web synchronization is used.
공용 속성ValidateGets or sets whether data validation is performed on the Subscriber data at the end of the synchronization.
공용 속성WorkingDirectoryGets or sets the working directory from which snapshot files are accessed when FTP is used.
맨 위로 이동

  이름설명
공용 메서드Abort인프라입니다. Aborts the synchronization.
공용 메서드ClearAllTraceFlags인프라입니다. Clears all the trace flags used by the synchronization agent.
공용 메서드ClearTraceFlag인프라입니다. Clears a trace flag.
공용 메서드CreateObjRef보안에 중요합니다. (MarshalByRefObject에서 상속됨)
공용 메서드Dispose()인프라입니다. Releases the unmanaged resources that are used by MergeSynchronizationAgent.
보호된 메서드Dispose(Boolean)인프라입니다. Releases the unmanaged resources that are used by MergeSynchronizationAgent.
공용 메서드EnableTraceFlag인프라입니다. Enables the flag tracing.
공용 메서드Equals (Object에서 상속됨)
보호된 메서드Finalize인프라입니다. Finalizes the agent. (Object.Finalize()을(를) 재정의함)
공용 메서드GetHashCode (Object에서 상속됨)
공용 메서드GetLifetimeService보안에 중요합니다. (MarshalByRefObject에서 상속됨)
공용 메서드GetType (Object에서 상속됨)
공용 메서드InitializeLifetimeService보안에 중요합니다. (MarshalByRefObject에서 상속됨)
공용 메서드IsSnapshotRequiredConnects to the Publisher or Distributor and the Subscriber to determine whether a new snapshot will be applied during the next agent synchronization.
보호된 메서드MemberwiseClone() (Object에서 상속됨)
보호된 메서드MemberwiseClone(Boolean) (MarshalByRefObject에서 상속됨)
공용 메서드ProcessMessagesAtPublisher인프라입니다. Processes the messages at publisher.
공용 메서드ProcessMessagesAtSubscriber인프라입니다. Processes the messages at subscriber.
공용 메서드SynchronizeStarts the Merge Agent to synchronize the subscription.
공용 메서드ToString (Object에서 상속됨)
맨 위로 이동

  이름설명
공용 이벤트ComStatus인프라입니다. Occurs when the Merge Agent returns synchronization Com status information.
공용 이벤트StatusOccurs when the Merge Agent returns synchronization status information.
맨 위로 이동

The MergeSynchronizationAgent class supports the ability to do the following replication tasks:

  • Synchronize subscriptions.

  • Specify whether only the upload phase, only the download phase, or both phases are run during synchronization.

  • Validate that a subscription has the expected data.

  • Specify a different snapshot folder, from which the initial snapshot for a subscription can be applied.

In the following example, the Synchronize method is called on the instance of the MergeSynchronizationAgent 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 = "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

In the following example, an instance of the MergeSynchronizationAgent class is used to synchronize a merge subscription. Because the pull subscription was created by using a value of false for CreateSyncAgentByDefault, additional properties must be supplied.

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

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

커뮤니티 추가 항목

추가
표시: