TransPullSubscription クラス
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
トランザクション出版物へのプルサブスクリプションを表します。
public ref class TransPullSubscription sealed : Microsoft::SqlServer::Replication::PullSubscription
public sealed class TransPullSubscription : Microsoft.SqlServer.Replication.PullSubscription
type TransPullSubscription = class
inherit PullSubscription
Public NotInheritable Class TransPullSubscription
Inherits PullSubscription
- 継承
例
// Define the Publisher, publication, and databases.
string publicationName = "AdvWorksProductTran";
string publisherName = publisherInstance;
string subscriberName = subscriberInstance;
string subscriptionDbName = "AdventureWorks2012Replica";
string publicationDbName = "AdventureWorks2012";
//Create connections to the Publisher and Subscriber.
ServerConnection subscriberConn = new ServerConnection(subscriberName);
ServerConnection publisherConn = new ServerConnection(publisherName);
// Create the objects that we need.
TransPublication publication;
TransPullSubscription subscription;
try
{
// Connect to the Publisher and Subscriber.
subscriberConn.Connect();
publisherConn.Connect();
// Ensure that the publication exists and that
// it supports pull subscriptions.
publication = new TransPublication();
publication.Name = publicationName;
publication.DatabaseName = publicationDbName;
publication.ConnectionContext = publisherConn;
if (publication.IsExistingObject)
{
if ((publication.Attributes & PublicationAttributes.AllowPull) == 0)
{
publication.Attributes |= PublicationAttributes.AllowPull;
}
// Define the pull subscription.
subscription = new TransPullSubscription();
subscription.ConnectionContext = subscriberConn;
subscription.PublisherName = publisherName;
subscription.PublicationName = publicationName;
subscription.PublicationDBName = publicationDbName;
subscription.DatabaseName = subscriptionDbName;
// Specify the Windows login credentials for the Distribution Agent job.
subscription.SynchronizationAgentProcessSecurity.Login = winLogin;
subscription.SynchronizationAgentProcessSecurity.Password = winPassword;
// Make sure that the agent job for the subscription is created.
subscription.CreateSyncAgentByDefault = true;
// By default, subscriptions to transactional publications are synchronized
// continuously, but in this case we only want to synchronize on demand.
subscription.AgentSchedule.FrequencyType = ScheduleFrequencyType.OnDemand;
// Create the pull subscription at the Subscriber.
subscription.Create();
Boolean registered = false;
// Verify that the subscription is not already registered.
foreach (TransSubscription existing
in publication.EnumSubscriptions())
{
if (existing.SubscriberName == subscriberName
&& existing.SubscriptionDBName == subscriptionDbName)
{
registered = true;
}
}
if (!registered)
{
// Register the subscription with the Publisher.
publication.MakePullSubscriptionWellKnown(
subscriberName, subscriptionDbName,
SubscriptionSyncType.Automatic,
TransSubscriberType.ReadOnly);
}
}
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 = "AdvWorksProductTran"
Dim publisherName As String = publisherInstance
Dim subscriberName As String = subscriberInstance
Dim subscriptionDbName As String = "AdventureWorks2012Replica"
Dim publicationDbName As String = "AdventureWorks2012"
'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 TransPublication
Dim subscription As TransPullSubscription
Try
' Connect to the Publisher and Subscriber.
subscriberConn.Connect()
publisherConn.Connect()
' Ensure that the publication exists and that
' it supports pull subscriptions.
publication = New TransPublication()
publication.Name = publicationName
publication.DatabaseName = publicationDbName
publication.ConnectionContext = publisherConn
If publication.IsExistingObject Then
If (publication.Attributes And PublicationAttributes.AllowPull) = 0 Then
publication.Attributes = publication.Attributes _
Or PublicationAttributes.AllowPull
End If
' Define the pull subscription.
subscription = New TransPullSubscription()
subscription.ConnectionContext = subscriberConn
subscription.PublisherName = publisherName
subscription.PublicationName = publicationName
subscription.PublicationDBName = publicationDbName
subscription.DatabaseName = subscriptionDbName
subscription.Description = "Pull subscription to " + publicationDbName _
+ " on " + subscriberName + "."
' Specify the Windows login credentials for the Distribution Agent job.
subscription.SynchronizationAgentProcessSecurity.Login = winLogin
subscription.SynchronizationAgentProcessSecurity.Password = winPassword
' Make sure that the agent job for the subscription is created.
subscription.CreateSyncAgentByDefault = True
' By default, subscriptions to transactional publications are synchronized
' continuously, but in this case we only want to synchronize on demand.
subscription.AgentSchedule.FrequencyType = ScheduleFrequencyType.OnDemand
' 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 TransSubscription In publication.EnumSubscriptions()
If existing.SubscriberName = subscriberName And _
existing.SubscriptionDBName = subscriptionDbName Then
registered = True
End If
Next existing
If Not registered Then
' Register the subscription with the Publisher.
publication.MakePullSubscriptionWellKnown( _
subscriberName, subscriptionDbName, _
SubscriptionSyncType.Automatic, _
TransSubscriberType.ReadOnly)
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)メンバーはマルチスレッド操作に安全です。 インスタンス メンバーがスレッド セーフであるとは限りません。
コンストラクター
| 名前 | 説明 |
|---|---|
| TransPullSubscription() |
TransPullSubscription クラスの新しいインスタンスを作成します。 |
| TransPullSubscription(String, String, String, String, ServerConnection, Boolean) |
プルサブスクリプションを定義するプロパティと、サブスクリプションのためにエージェントジョブを作成するかどうかを決める新しいインスタンス TransPullSubscription クラスを作成します。 |
| TransPullSubscription(String, String, String, String, ServerConnection) |
プルサブスクリプションを定義するプロパティを持つ新しい TransPullSubscription クラスのインスタンスを作成します。 |
プロパティ
| 名前 | 説明 |
|---|---|
| AgentJobId |
サブスクリプション同期に使われたエージェントジョブのIDを取得します。 (継承元 PullSubscription) |
| AgentOffload |
同期エージェントがエージェントジョブが作成されたコンピュータ以外のコンピュータ上で動作するかどうかを取得または設定します。 このプロパティは、Microsoft SQL Server 2005以降のディストリビューターではもはやサポートされていません。 (継承元 PullSubscription) |
| AgentOffloadServer |
リモートエージェントのアクティベーション時にエージェントが動作するリモートコンピュータの名前を取得したり設定したりします。 (継承元 PullSubscription) |
| AgentSchedule |
サブスクリプション同期に使われるエージェントジョブのスケジュールを取得します。 (継承元 PullSubscription) |
| AltSnapshotFolder |
ディストリビューターのデフォルトのスナップショット場所が使われていない場合、出版スナップショットファイルを取得する場所を取得または設定します。 (継承元 PullSubscription) |
| Attributes |
サブスクリプションでサポートされているトランザクション出版物の属性を取得したり設定したりします。 |
| CachePropertyChanges |
レプリケーションプロパティの変更をキャッシュするか、即座に適用するかを取得または設定します。 (継承元 ReplicationObject) |
| ConnectionContext |
Microsoft SQL Serverのインスタンスへの接続を取得または設定します。 (継承元 ReplicationObject) |
| CreateSyncAgentByDefault |
サブスクリプションを同期させるためにレプリケーションエージェントを起動するために使ったエージェントジョブが、サブスクリプション作成時に作成されるかどうかを取得または設定します。 (継承元 PullSubscription) |
| DatabaseName |
サブスクリプションデータベースの名前を取得するか設定します。 (継承元 PullSubscription) |
| Description |
プルサブスクリプションのテキスト説明を取得または設定します。 (継承元 PullSubscription) |
| DistributorName |
配布者であるMicrosoft SQL Serverのインスタンスを取得し、購読者が購読する出版物を配信します。 (継承元 PullSubscription) |
| DistributorSecurity |
ディストリビューターに接続する際に使われるセキュリティコンテキストを取得します。 (継承元 PullSubscription) |
| DtsPackageLocation |
変換可能なサブスクリプションで使用されるデータ変換サービス(DTS)パッケージの位置を取得したり設定したりします。 |
| DtsPackageName |
変換可能なサブスクリプションで使用されるData Transformation Services(DTS)パッケージ名を取得したり設定したりします。 |
| DtsPackagePassword |
変換可能なサブスクリプションで使われるパスワードを取得または設定します。 |
| EnabledForSynchronizationManager |
Windows同期マネージャーで同期できるかどうかを指定します。 (継承元 PullSubscription) |
| FtpAddress |
FTPサーバーのIPアドレスを取得するか設定します。 (継承元 PullSubscription) |
| FtpLogin |
FTPログインの取得または設定。 (継承元 PullSubscription) |
| FtpPassword |
FTPのパスワードを取得するか設定します。 (継承元 PullSubscription) |
| FtpPort |
FTPサーバーのポート番号を取得するか設定します。 (継承元 PullSubscription) |
| IsExistingObject |
オブジェクトがサーバー上に存在するかどうかを把握します。 (継承元 ReplicationObject) |
| IsMemoryOptimized |
トランザクション出版物へのプルサブスクリプションを表します。 (継承元 PullSubscription) |
| LastAgentDateTime |
購読が最後に同期された日時を取得します。 (継承元 PullSubscription) |
| LastAgentStatus |
最新の同期状況を取得します。 (継承元 PullSubscription) |
| LastAgentSummary |
最新の同期結果の概要を取得できます。 (継承元 PullSubscription) |
| LastSummaryDateTime |
最後の同期が完了した日時を取得します。 |
| MemoryOptimized |
トランザクション出版物へのプルサブスクリプションを表します。 |
| Name |
プルサブスクリプションの名前が生成されます。 (継承元 PullSubscription) |
| PublicationDBName |
出版物データベースの名前を取得するか設定します。 (継承元 PullSubscription) |
| PublicationName |
購読者が購読している出版物の名前を取得するか設定します。 (継承元 PullSubscription) |
| PublisherName |
Publisherの名前を取得するか設定します。 (継承元 PullSubscription) |
| PublisherSecurity |
Publisherに接続する際に同期エージェントが使用するセキュリティコンテキストを取得したり設定したりします。 (継承元 PullSubscription) |
| SecureFtpPassword |
FTPサーバーに接続するログインのセキュアパスワードを取得したり設定したりします。 (継承元 PullSubscription) |
| SqlServerName |
このオブジェクトが接続されているMicrosoft SQL Serverインスタンスの名前を取得します。 (継承元 ReplicationObject) |
| SubscriberSecurity |
加入者に接続する際に同期エージェントが使用するセキュリティコンテキストを取得します。 (継承元 PullSubscription) |
| SubscriberType |
サブスクリプションの更新動作を取得または設定します。 |
| SubscriptionId |
サブスクリプションIDの値を取得します。 (継承元 PullSubscription) |
| SubscriptionType |
購読登録がプッシュ、プル、匿名のどれかを把握します。 (継承元 PullSubscription) |
| SynchronizationAgent |
サブスクリプションの同期に使用できるディストリビューション エージェントのインスタンスを表すオブジェクトを取得します。 |
| SynchronizationAgentProcessSecurity |
同期エージェントジョブが実行されるMicrosoft Windowsアカウントを指定するためのセキュリティコンテキストを取得します。 (継承元 PullSubscription) |
| Type |
出版タイプを取得するか設定します。 (継承元 PullSubscription) |
| UseFtp |
プルサブスクリプションの初期化に必要なスナップショットファイルが、ファイル転送プロトコル(FTP)を用いて同期エージェントによってアクセスされるかどうかを取得または設定します。 (継承元 PullSubscription) |
| UserData |
ユーザーが自分のデータをオブジェクトにアタッチできるオブジェクトプロパティを取得したり設定したりします。 (継承元 ReplicationObject) |
| WorkingDirectory |
サブスクライバーのディレクトリのパスを取得し、ダウンロードしたスナップショットファイルを一時的に保存・解凍するために設定します。 (継承元 PullSubscription) |