MergePullSubscription クラス

定義

合併出版物へのプル購読を表しています。

public ref class MergePullSubscription sealed : Microsoft::SqlServer::Replication::PullSubscription
public sealed class MergePullSubscription : Microsoft.SqlServer.Replication.PullSubscription
type MergePullSubscription = class
    inherit PullSubscription
Public NotInheritable Class MergePullSubscription
Inherits PullSubscription
継承
MergePullSubscription

// Define the Publisher, publication, and databases.
string publicationName = "AdvWorksSalesOrdersMerge";
string publisherName = publisherInstance;
string subscriberName = subscriberInstance;
string subscriptionDbName = "AdventureWorks2012Replica";
string publicationDbName = "AdventureWorks2012";
string hostname = @"adventure-works\garrett1";

//Create connections to the Publisher and Subscriber.
ServerConnection subscriberConn = new ServerConnection(subscriberName);
ServerConnection publisherConn = new ServerConnection(publisherName);

// Create the objects that we need.
MergePublication publication;
MergePullSubscription subscription;

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

    // Ensure that the publication exists and that 
    // it supports pull subscriptions.
    publication = new MergePublication();
    publication.Name = publicationName;
    publication.DatabaseName = publicationDbName;
    publication.ConnectionContext = publisherConn;

    if (publication.LoadProperties())
    {
        if ((publication.Attributes & PublicationAttributes.AllowPull) == 0)
        {
            publication.Attributes |= PublicationAttributes.AllowPull;
        }

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

        // Specify the Windows login credentials for the Merge Agent job.
        subscription.SynchronizationAgentProcessSecurity.Login = winLogin;
        subscription.SynchronizationAgentProcessSecurity.Password = winPassword;

        // Make sure that the agent job for the subscription is created.
        subscription.CreateSyncAgentByDefault = true;

        // Create the pull subscription at the Subscriber.
        subscription.Create();

        Boolean registered = false;

        // Verify that the subscription is not already registered.
        foreach (MergeSubscription existing
            in publication.EnumSubscriptions())
        {
            if (existing.SubscriberName == subscriberName
                && existing.SubscriptionDBName == subscriptionDbName
                && existing.SubscriptionType == SubscriptionOption.Pull)
            {
                registered = true;
            }
        }
        if (!registered)
        {
            // Register the local subscription with the Publisher.
            publication.MakePullSubscriptionWellKnown(
                subscriberName, subscriptionDbName,
                SubscriptionSyncType.Automatic,
                MergeSubscriberType.Local, 0);
        }
    }
    else
    {
        // Do something here if the publication does not exist.
        throw new ApplicationException(String.Format(
            "The publication '{0}' does not exist on {1}.",
            publicationName, publisherName));
    }
}
catch (Exception ex)
{
    // Implement the appropriate error handling here.
    throw new ApplicationException(String.Format(
        "The subscription to {0} could not be created.", publicationName), ex);
}
finally
{
    subscriberConn.Disconnect();
    publisherConn.Disconnect();
}
' Define the Publisher, publication, and databases.
Dim publicationName As String = "AdvWorksSalesOrdersMerge"
Dim publisherName As String = publisherInstance
Dim subscriberName As String = subscriberInstance
Dim subscriptionDbName As String = "AdventureWorks2012Replica"
Dim publicationDbName As String = "AdventureWorks2012"
Dim hostname As String = "adventure-works\garrett1"

'Create connections to the Publisher and Subscriber.
Dim subscriberConn As ServerConnection = New ServerConnection(subscriberName)
Dim publisherConn As ServerConnection = New ServerConnection(publisherName)

' Create the objects that we need.
Dim publication As MergePublication
Dim subscription As MergePullSubscription

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

    ' Ensure that the publication exists and that 
    ' it supports pull subscriptions.
    publication = New MergePublication()
    publication.Name = publicationName
    publication.DatabaseName = publicationDbName
    publication.ConnectionContext = publisherConn

    If publication.LoadProperties() Then
        If (publication.Attributes And PublicationAttributes.AllowPull) = 0 Then
            publication.Attributes = publication.Attributes _
            Or PublicationAttributes.AllowPull
        End If

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

        ' Specify the Windows login credentials for the Merge Agent job.
        subscription.SynchronizationAgentProcessSecurity.Login = winLogin
        subscription.SynchronizationAgentProcessSecurity.Password = winPassword

        ' Make sure that the agent job for the subscription is created.
        subscription.CreateSyncAgentByDefault = True

        ' Create the pull subscription at the Subscriber.
        subscription.Create()

        Dim registered As Boolean = False

        ' Verify that the subscription is not already registered.
        For Each existing As MergeSubscription In _
        publication.EnumSubscriptions()
            If existing.SubscriberName = subscriberName Then
                registered = True
            End If
        Next
        If Not registered Then
            ' Register the local subscription with the Publisher.
            publication.MakePullSubscriptionWellKnown( _
             subscriberName, subscriptionDbName, _
             SubscriptionSyncType.Automatic, _
             MergeSubscriberType.Local, 0)
        End If
    Else
        ' Do something here if the publication does not exist.
        Throw New ApplicationException(String.Format( _
         "The publication '{0}' does not exist on {1}.", _
         publicationName, publisherName))
    End If
Catch ex As Exception
    ' Implement the appropriate error handling here.
    Throw New ApplicationException(String.Format( _
        "The subscription to {0} could not be created.", publicationName), ex)
Finally
    subscriberConn.Disconnect()
    publisherConn.Disconnect()
End Try

注釈

プルサブスクリプションの場合、マージ エージェントはサブスクライバー側で動作します。

スレッド セーフ

このタイプの公開静的(Microsoft Visual BasicShared)メンバーはマルチスレッド操作に安全です。 インスタンス メンバーがスレッド セーフであるとは限りません。

コンストラクター

名前 説明
MergePullSubscription()

MergePullSubscription クラスの新しいインスタンスを作成します。

MergePullSubscription(String, String, String, String, ServerConnection, Boolean)

指定されたデータベース、Publisher、公開、サブスクライバー接続、エージェントジョブの作成かどうかを含み、MergePullSubscriptionクラスの新しいインスタンスを作成します。

MergePullSubscription(String, String, String, String, ServerConnection)

指定されたデータベース、Publisher、パブリケーション、サブスクライバー接続でMergePullSubscriptionクラスの新しいインスタンスを初期化します。

プロパティ

名前 説明
AgentJobId

サブスクリプション同期に使われたエージェントジョブのIDを取得します。

(継承元 PullSubscription)
AgentOffload

同期エージェントがエージェントジョブが作成されたコンピュータ以外のコンピュータ上で動作するかどうかを取得または設定します。 このプロパティは、Microsoft SQL Server 2005以降のディストリビューターではもはやサポートされていません。

(継承元 PullSubscription)
AgentOffloadServer

リモートエージェントのアクティベーション時にエージェントが動作するリモートコンピュータの名前を取得したり設定したりします。

(継承元 PullSubscription)
AgentSchedule

サブスクリプション同期に使われるエージェントジョブのスケジュールを取得します。

(継承元 PullSubscription)
AltSnapshotFolder

ディストリビューターのデフォルトのスナップショット場所が使われていない場合、出版スナップショットファイルを取得する場所を取得または設定します。

(継承元 PullSubscription)
CachePropertyChanges

レプリケーションプロパティの変更をキャッシュするか、即座に適用するかを取得または設定します。

(継承元 ReplicationObject)
ConnectionContext

Microsoft SQL Serverのインスタンスへの接続を取得または設定します。

(継承元 ReplicationObject)
CreateSyncAgentByDefault

サブスクリプションを同期させるためにレプリケーションエージェントを起動するために使ったエージェントジョブが、サブスクリプション作成時に作成されるかどうかを取得または設定します。

(継承元 PullSubscription)
DatabaseName

サブスクリプションデータベースの名前を取得するか設定します。

(継承元 PullSubscription)
Description

プルサブスクリプションのテキスト説明を取得または設定します。

(継承元 PullSubscription)
DistributorName

配布者であるMicrosoft SQL Serverのインスタンスを取得し、購読者が購読する出版物を配信します。

(継承元 PullSubscription)
DistributorSecurity

ディストリビューターに接続する際に使われるセキュリティコンテキストを取得します。

(継承元 PullSubscription)
DynamicSnapshotLocation

パブリケーションがパラメータ化された行フィルターを使用した場合、サブスクリプション固有のスナップショットファイルのファイル位置を取得したり設定したりします。

EnabledForSynchronizationManager

Windows同期マネージャーで同期できるかどうかを指定します。

(継承元 PullSubscription)
FtpAddress

FTPサーバーのIPアドレスを取得するか設定します。

(継承元 PullSubscription)
FtpLogin

FTPログインの取得または設定。

(継承元 PullSubscription)
FtpPassword

FTPのパスワードを取得するか設定します。

(継承元 PullSubscription)
FtpPort

FTPサーバーのポート番号を取得するか設定します。

(継承元 PullSubscription)
HostName

この関数が加入者のデータパーティションを定義するパラメータ化された行フィルターで使用される場合、 HOST_NAME 関数に提供された値を取得または設定します。

InternetLogin

Web同期時にWebサーバーに接続する際に、HTTP基本認証で使われるログイン情報を取得または設定します。

InternetPassword

ウェブ同期時にWebサーバーに接続する際、提供された InternetLogin 値のパスワードを取得したり設定したりします。

InternetSecurityMode

Web同期時にWebサーバーに接続する際に使われるHTTP認証方法を取得したり設定したりします。

InternetTimeout

Webサーバーに接続する際、Web同期時にHTTPタイムアウトを秒単位で取得または設定します。

InternetUrl

購読を同期する際に使用するURLを取得するか設定します。

IsExistingObject

オブジェクトがサーバー上に存在するかどうかを把握します。

(継承元 ReplicationObject)
IsMemoryOptimized

合併出版物へのプル購読を表しています。

(継承元 PullSubscription)
LastAgentDateTime

購読が最後に同期された日時を取得します。

(継承元 PullSubscription)
LastAgentStatus

最新の同期状況を取得します。

(継承元 PullSubscription)
LastAgentSummary

最新の同期結果の概要を取得できます。

(継承元 PullSubscription)
Name

プルサブスクリプションの名前が生成されます。

(継承元 PullSubscription)
Priority

サブスクリプション間の競合を解決する際に、このサーバーのサブスクリプションの重み付けを他のサーバーサブスクリプションと比較して取得または設定します。

PublicationDBName

出版物データベースの名前を取得するか設定します。

(継承元 PullSubscription)
PublicationName

購読者が購読している出版物の名前を取得するか設定します。

(継承元 PullSubscription)
PublisherName

Publisherの名前を取得するか設定します。

(継承元 PullSubscription)
PublisherSecurity

Publisherに接続する際に同期エージェントが使用するセキュリティコンテキストを取得したり設定したりします。

(継承元 PullSubscription)
SecureFtpPassword

FTPサーバーに接続するログインのセキュアパスワードを取得したり設定したりします。

(継承元 PullSubscription)
SecureInternetPassword

HTTP基本認証を使ってWebサーバーに接続する際に使うパスワード( SecureString オブジェクトとして)を設定します。

SqlServerName

このオブジェクトが接続されているMicrosoft SQL Serverインスタンスの名前を取得します。

(継承元 ReplicationObject)
SubscriberSecurity

加入者に接続する際に同期エージェントが使用するセキュリティコンテキストを取得します。

(継承元 PullSubscription)
SubscriberType

サブスクリプションがサーバーかクライアントかの取得か設定します。

SubscriptionId

サブスクリプションIDの値を取得します。

(継承元 PullSubscription)
SubscriptionType

購読登録がプッシュ、プル、匿名のどれかを把握します。

(継承元 PullSubscription)
SynchronizationAgent

サブスクリプションの同期に使えるマージ エージェントのインスタンスを表すオブジェクトを取得します。

SynchronizationAgentProcessSecurity

同期エージェントジョブが実行されるMicrosoft Windowsアカウントを指定するためのセキュリティコンテキストを取得します。

(継承元 PullSubscription)
SyncType

サブスクライバーでデータの初期化方法を取得または設定します。

Type

出版タイプを取得するか設定します。

(継承元 PullSubscription)
UseFtp

プルサブスクリプションの初期化に必要なスナップショットファイルが、ファイル転送プロトコル(FTP)を用いて同期エージェントによってアクセスされるかどうかを取得または設定します。

(継承元 PullSubscription)
UseInteractiveResolver

同期プロセス中にインタラクティブリゾルバを使用するかどうかを取得または設定します。

UserData

ユーザーが自分のデータをオブジェクトにアタッチできるオブジェクトプロパティを取得したり設定したりします。

(継承元 ReplicationObject)
UseWebSynchronization

サブスクリプションがWeb同期で同期されているかどうかを取得または設定します。

WorkingDirectory

サブスクライバーのディレクトリのパスを取得し、ダウンロードしたスナップショットファイルを一時的に保存・解凍するために設定します。

(継承元 PullSubscription)

メソッド

名前 説明
CheckValidCreation()

有効な複製の作成を確認します。

(継承元 ReplicationObject)
CheckValidDefinition(Boolean)

定義が有効かどうかを示します。

(継承元 PullSubscription)
CommitPropertyChanges()

キャッシュされたプロパティ変更文をすべてMicrosoft SQL Serverのインスタンスに送信します。

(継承元 ReplicationObject)
Create()

購読者に対してプルサブスクリプションを作成します。

(継承元 PullSubscription)
CustomEnabledForSyncMgr(StringBuilder)

同期マネージャのカスタム公開を可能にします。

(継承元 PullSubscription)
Decouple()

参照されたレプリケーションオブジェクトをサーバーから切り離します。

(継承元 ReplicationObject)
EnumSynchronizationPartners()

代替同期パートナーを戻す

GetChangeCommand(StringBuilder, String, String)

レプリケーションからの変更コマンドを返します。

(継承元 ReplicationObject)
GetCreateCommand(StringBuilder, Boolean, ScriptOptions)

レプリケーションからcreateコマンドを返します。

(継承元 ReplicationObject)
GetDropCommand(StringBuilder, Boolean)

レプリケーションからドロップコマンドを返します。

(継承元 ReplicationObject)
InitMemberVariables(String, String, String, String, Boolean)

メンバー変数を初期化します。

(継承元 PullSubscription)
InternalRefresh(Boolean)

レプリケーションから内部リフレッシュを開始します。

(継承元 ReplicationObject)
LastAgentJobHistoryInfo()

最後に実行された同期エージェントのジョブ情報を返します。

(継承元 PullSubscription)
Load()

サーバーから既存のオブジェクトのプロパティを読み込みます。

(継承元 ReplicationObject)
LoadProperties()

サーバーから既存のオブジェクトのプロパティを読み込みます。

(継承元 ReplicationObject)
Refresh()

オブジェクトのプロパティをリロードします。

(継承元 ReplicationObject)
Reinitialize(Boolean)

マージプルサブスクリプションを初期化のためにマークします。

Remove()

プルサブスクリプションを解除します。

(継承元 PullSubscription)
Script(ScriptOptions)

PullSubscriptionオブジェクトの現在のプロパティ設定に基づいてプルサブスクリプションを作成または削除するための Transact-SQL スクリプトを返します。

(継承元 PullSubscription)
StopSynchronizationJob()

現在サブスクリプションを同期している実行中のマージ エージェントジョブを停止しようとします。

SynchronizeWithJob()

エージェントジョブを非同期で開始し、プルサブスクリプションを同期させます。

適用対象

こちらもご覧ください