TransPullSubscription.SynchronizeWithJob TransPullSubscription.SynchronizeWithJob TransPullSubscription.SynchronizeWithJob Method

정의

구독을 동기화하는 에이전트 작업을 시작합니다. Starts the agent job to synchronize the subscription.

public:
 override void SynchronizeWithJob();
public override void SynchronizeWithJob ();
Public Overrides Sub SynchronizeWithJob ()

예제

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

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

TransPullSubscription subscription;

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

	// Define subscription properties.
	subscription = new TransPullSubscription();
	subscription.ConnectionContext = conn;
             subscription.DatabaseName = subscriptionDbName;
	subscription.PublisherName = publisherName;
	subscription.PublicationDBName = publicationDbName;
	subscription.PublicationName = publicationName;

	// If the pull subscription and the job exists, start the agent job.
	if (subscription.LoadProperties() && subscription.AgentJobId != null)
	{
		subscription.SynchronizeWithJob();
	}
	else
	{
		// Do something here if the subscription does not exist.
		throw new ApplicationException(String.Format(
			"A subscription to '{0}' does not exists on {1}",
			publicationName, subscriberName));
	}
}
catch (Exception ex)
{
	// Do appropriate error handling here.
	throw new ApplicationException("The subscription could not be synchronized.", ex);
}
finally
{
	conn.Disconnect();
}
' Define server, publication, and database names.
Dim subscriberName As String = subscriberInstance
Dim publisherName As String = publisherInstance
Dim publicationName As String = "AdvWorksProductTran"
Dim publicationDbName As String = "AdventureWorks2012"
Dim subscriptionDbName As String = "AdventureWorks2012Replica"

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

Dim subscription As TransPullSubscription

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

    ' Define subscription properties.
    subscription = New TransPullSubscription()
    subscription.ConnectionContext = conn
    subscription.DatabaseName = subscriptionDbName
    subscription.PublisherName = publisherName
    subscription.PublicationDBName = publicationDbName
    subscription.PublicationName = publicationName

    ' If the pull subscription and the job exists, start the agent job.
    If subscription.LoadProperties() And Not subscription.AgentJobId Is Nothing Then
        subscription.SynchronizeWithJob()
    Else
        ' Do something here if the subscription does not exist.
        Throw New ApplicationException(String.Format( _
         "A subscription to '{0}' does not exists on {1}", _
         publicationName, subscriberName))
    End If
Catch ex As Exception
    ' Do appropriate error handling here.
    Throw New ApplicationException("The subscription could not be synchronized.", ex)
Finally
    conn.Disconnect()
End Try

설명

사용 하 여는 TransSynchronizationAgent 에서 반환 된 개체는 SynchronizationAgent 배포 에이전트를 동기적으로 시작 하는 속성입니다.Use the TransSynchronizationAgent object returned by the SynchronizationAgent property to start the Distribution Agent synchronously.

값이 끌어오기 구독을 만든 경우 false 에 대 한 CreateSyncAgentByDefault, 기본값, 구독에 대 한 배포 에이전트 작업은 생성 되 고 호출 SynchronizeWithJob 하면 예외가 발생 합니다.If the pull subscription is created with a value of false for CreateSyncAgentByDefault, the default, a Distribution Agent job for the subscription is not created and calling SynchronizeWithJob causes an exception.

호출 된 StopSynchronizationJob 현재 실행 중인 작업을 중지 하는 메서드.Call the StopSynchronizationJob method to stop the job if it is currently running.

작업을 시작 하기 위해 수 없으면는 Microsoft SQL Server 에이전트 서비스가 실행 되지 않습니다.The job is not able to start if the Microsoft SQL Server Agent Service is not running. 또한 스냅숏으로 생성 되지 않은 경우 에이전트 작업을 실행 수 하지 구독을 동기화 합니다.Also if a snapshot is not generated, running the agent job may not synchronize the subscription.

이 인스턴스의 추가 속성을 설정한 경우 TransPullSubscription, 호출 CommitPropertyChanges 호출 하기 전에 SynchronizeWithJob합니다.If you have set additional properties on this instance of TransPullSubscription, call CommitPropertyChanges before calling SynchronizeWithJob.

SynchronizeWithJob 메서드의 구성원만 호출할 수는 sysadmin 고정된 서버 역할의 멤버 또는 구독자에서의 db_owner 구독 데이터베이스의 고정된 데이터베이스 역할입니다.The SynchronizeWithJob method can only be called by members of the sysadmin fixed server role at the Subscriber or by members of the db_owner fixed database role on the subscription database.

적용 대상

추가 정보