MergeSubscription クラス
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
Publisherに登録された合併出版物の購読を表します。
public ref class MergeSubscription sealed : Microsoft::SqlServer::Replication::Subscription
public sealed class MergeSubscription : Microsoft.SqlServer.Replication.Subscription
type MergeSubscription = class
inherit Subscription
Public NotInheritable Class MergeSubscription
Inherits Subscription
- 継承
例
// 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 a connection to the Publisher.
ServerConnection conn = new ServerConnection(publisherName);
// Create the objects that we need.
MergePublication publication;
MergeSubscription subscription;
try
{
// Connect to the Publisher.
conn.Connect();
// Ensure that the publication exists and that
// it supports push subscriptions.
publication = new MergePublication();
publication.Name = publicationName;
publication.DatabaseName = publicationDbName;
publication.ConnectionContext = conn;
if (publication.IsExistingObject)
{
if ((publication.Attributes & PublicationAttributes.AllowPush) == 0)
{
publication.Attributes |= PublicationAttributes.AllowPush;
}
// Define the push subscription.
subscription = new MergeSubscription();
subscription.ConnectionContext = conn;
subscription.SubscriberName = subscriberName;
subscription.PublicationName = publicationName;
subscription.DatabaseName = publicationDbName;
subscription.SubscriptionDBName = subscriptionDbName;
subscription.HostName = hostname;
// Set a schedule to synchronize the subscription every 2 hours
// during weekdays from 6am to 10pm.
subscription.AgentSchedule.FrequencyType = ScheduleFrequencyType.Weekly;
subscription.AgentSchedule.FrequencyInterval = Convert.ToInt32(0x003E);
subscription.AgentSchedule.FrequencyRecurrenceFactor = 1;
subscription.AgentSchedule.FrequencySubDay = ScheduleFrequencySubDay.Hour;
subscription.AgentSchedule.FrequencySubDayInterval = 2;
subscription.AgentSchedule.ActiveStartDate = 20051108;
subscription.AgentSchedule.ActiveEndDate = 20071231;
subscription.AgentSchedule.ActiveStartTime = 060000;
subscription.AgentSchedule.ActiveEndTime = 100000;
// Specify the Windows login credentials for the Merge Agent job.
subscription.SynchronizationAgentProcessSecurity.Login = winLogin;
subscription.SynchronizationAgentProcessSecurity.Password = winPassword;
// Create the push subscription.
subscription.Create();
}
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
{
conn.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 a connection to the Publisher.
Dim conn As ServerConnection = New ServerConnection(publisherName)
' Create the objects that we need.
Dim publication As MergePublication
Dim subscription As MergeSubscription
Try
' Connect to the Publisher.
conn.Connect()
' Ensure that the publication exists and that
' it supports push subscriptions.
publication = New MergePublication()
publication.Name = publicationName
publication.DatabaseName = publicationDbName
publication.ConnectionContext = conn
If publication.IsExistingObject Then
If (publication.Attributes And PublicationAttributes.AllowPush) = 0 Then
publication.Attributes = publication.Attributes _
Or PublicationAttributes.AllowPush
End If
' Define the push subscription.
subscription = New MergeSubscription()
subscription.ConnectionContext = conn
subscription.SubscriberName = subscriberName
subscription.PublicationName = publicationName
subscription.DatabaseName = publicationDbName
subscription.SubscriptionDBName = subscriptionDbName
subscription.HostName = hostname
' Set a schedule to synchronize the subscription every 2 hours
' during weekdays from 6am to 10pm.
subscription.AgentSchedule.FrequencyType = ScheduleFrequencyType.Weekly
subscription.AgentSchedule.FrequencyInterval = Convert.ToInt32("0x003E", 16)
subscription.AgentSchedule.FrequencyRecurrenceFactor = 1
subscription.AgentSchedule.FrequencySubDay = ScheduleFrequencySubDay.Hour
subscription.AgentSchedule.FrequencySubDayInterval = 2
subscription.AgentSchedule.ActiveStartDate = 20051108
subscription.AgentSchedule.ActiveEndDate = 20071231
subscription.AgentSchedule.ActiveStartTime = 60000
subscription.AgentSchedule.ActiveEndTime = 100000
' Specify the Windows login credentials for the Merge Agent job.
subscription.SynchronizationAgentProcessSecurity.Login = winLogin
subscription.SynchronizationAgentProcessSecurity.Password = winPassword
' Create the push subscription.
subscription.Create()
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
conn.Disconnect()
End Try
注釈
MergeSubscriptionクラスは、マージ出版物のプルおよびプッシュサブスクリプションの両方で使用されます。
リモートディストリビューターでPublisherを設定する際、SynchronizationAgentProcessSecurityを含むすべてのパラメータの値がプレーンテキストでディストリビュータに送信されます。 Create メソッドを呼び出す前に、パブリッシャーとリモート ディストリビューター間の接続を暗号化する必要があります。 詳細については、 sp_reinitmergesubscription(Transact-SQL)を参照してください。
スレッド セーフ
このタイプの公開静的(Microsoft Visual BasicShared)メンバーはマルチスレッド操作に安全です。 インスタンス メンバーがスレッド セーフであるとは限りません。
コンストラクター
| 名前 | 説明 |
|---|---|
| MergeSubscription() |
MergeSubscription クラスの新しいインスタンスを作成します。 |
| MergeSubscription(String, String, String, String, ServerConnection) |
Publisherとサブスクリプションを一意に定義するプロパティを持つMergeSubscriptionクラスの新しいインスタンスを作成します。 |
プロパティ
| 名前 | 説明 |
|---|---|
| AgentJobId |
サブスクリプション同期に使われたエージェントジョブのIDを取得します。 (継承元 Subscription) |
| AgentOffload |
同期エージェントがエージェントジョブが作成されたコンピュータ以外のコンピュータ上で動作するかを取得または設定します。 このプロパティは、Microsoft SQL Server 2005以降のディストリビューターではもはやサポートされていません。 (継承元 Subscription) |
| AgentOffloadServer |
リモートエージェントのアクティベーション時にエージェントが動作するリモートコンピュータの名前を取得したり設定したりします。 (継承元 Subscription) |
| AgentSchedule |
サブスクリプション同期に使われるエージェントジョブのスケジュールを取得します。 (継承元 Subscription) |
| CachePropertyChanges |
レプリケーションプロパティの変更をキャッシュするか、即座に適用するかを取得または設定します。 (継承元 ReplicationObject) |
| ConnectionContext |
Microsoft SQL Serverのインスタンスへの接続を取得または設定します。 (継承元 ReplicationObject) |
| CreateSyncAgentByDefault |
サブスクリプション同期に使われるエージェントジョブがデフォルトで作成されるかどうかを取得または設定します。 (継承元 Subscription) |
| DatabaseName |
出版物データベースの名前を取得するか設定します。 (継承元 Subscription) |
| Description |
マージサブスクリプションのテキスト説明を取得したり設定したりします。 |
| EnabledForSynchronizationManager |
同期マネージャーを使ってサブスクリプションを同期できるかどうかMicrosoft Windows指定します。 (継承元 Subscription) |
| HostName |
この関数が加入者のデータパーティションを定義するパラメータ化された行フィルターで使用される場合、 HOST_NAME 関数に提供された値を取得または設定します。 |
| IsExistingObject |
オブジェクトがサーバー上に存在するかどうかを把握します。 (継承元 ReplicationObject) |
| Name |
既存のサブスクリプションに名前が割り当てられます。 (継承元 Subscription) |
| Priority |
サーバーサブスクリプションに割り当てられた相対的な優先度値を取得または設定します。 |
| PublicationName |
購読者が購読している出版物の名前を取得するか設定します。 (継承元 Subscription) |
| PublisherSecurity |
マージ エージェントがPublisherに接続するために使用するセキュリティコンテキストを取得します。 |
| SqlServerName |
このオブジェクトが接続されているMicrosoft SQL Serverインスタンスの名前を取得します。 (継承元 ReplicationObject) |
| Status |
サブスクリプションの状況を把握します。 (継承元 Subscription) |
| SubscriberName |
サブスクライバーであるMicrosoft SQL Serverのインスタンス名を取得したり設定したりします。 (継承元 Subscription) |
| SubscriberSecurity |
加入者に接続する際に使われるセキュリティコンテキストを取得します。 (継承元 Subscription) |
| SubscriberType |
サブスクリプションがクライアントかサーバーかを取得または設定します。 |
| SubscriptionDBName |
複製されたデータを受け取ったサブスクライバーのデータベース名を取得するか設定します。 (継承元 Subscription) |
| SubscriptionType |
サブスクリプション登録がプッシュ用かプル用かを把握します。 (継承元 Subscription) |
| SynchronizationAgent |
サブスクリプションの同期に使える MergeSynchronizationAgent クラスのインスタンスを取得します。 |
| SynchronizationAgentName |
サブスクリプションを同期するために作成されたエージェントジョブの名前を取得したり設定したりします。 (継承元 Subscription) |
| SynchronizationAgentProcessSecurity |
同期エージェントジョブが実行されるMicrosoft Windowsアカウントを指定するためのセキュリティコンテキストを取得し、サブスクリプションを同期させます。 (継承元 Subscription) |
| SyncType |
サブスクリプションの初期化方法を取得または設定します。 (継承元 Subscription) |
| UseInteractiveResolver |
同期プロセス中にインタラクティブリゾルバを使用するかどうかを取得または設定します。 |
| UserData |
ユーザーが自分のデータをオブジェクトにアタッチできるオブジェクトプロパティを取得したり設定したりします。 (継承元 ReplicationObject) |
メソッド
| 名前 | 説明 |
|---|---|
| CheckValidCreation() |
有効な複製の作成を確認します。 (継承元 ReplicationObject) |
| CheckValidDefinition(Boolean) |
サブスクリプションの定義が有効かどうかを示します。 (継承元 Subscription) |
| CommitPropertyChanges() |
キャッシュされたプロパティ変更文をすべてMicrosoft SQL Serverのインスタンスに送信します。 (継承元 ReplicationObject) |
| Create() |
Publisherで購読登録を作成します。 (継承元 Subscription) |
| Decouple() |
参照されたレプリケーションオブジェクトをサーバーから切り離します。 (継承元 ReplicationObject) |
| GetChangeCommand(StringBuilder, String, String) |
レプリケーションからの変更コマンドを返します。 (継承元 ReplicationObject) |
| GetCreateCommand(StringBuilder, Boolean, ScriptOptions) |
レプリケーションからcreateコマンドを返します。 (継承元 ReplicationObject) |
| GetDropCommand(StringBuilder, Boolean) |
レプリケーションからドロップコマンドを返します。 (継承元 ReplicationObject) |
| InternalRefresh(Boolean) |
レプリケーションから内部リフレッシュを開始します。 (継承元 ReplicationObject) |
| Load() |
サーバーから既存のオブジェクトのプロパティを読み込みます。 (継承元 ReplicationObject) |
| LoadProperties() |
サーバーから既存のオブジェクトのプロパティを読み込みます。 (継承元 ReplicationObject) |
| Refresh() |
オブジェクトのプロパティをリロードします。 (継承元 ReplicationObject) |
| Reinitialize(Boolean) |
再初期化のためのマージサブスクリプションを示します。 |
| Remove() |
Publisherでのサブスクリプション登録を削除し、Subscriberのプッシュサブスクリプションのレプリケーションオブジェクトを削除します。 (継承元 Subscription) |
| Script(ScriptOptions) |
サブスクリプションの作成または削除に使える Transact-SQL スクリプトを返します。 (継承元 Subscription) |
| StopSynchronizationJob() |
現在サブスクリプションを同期している実行中のマージ エージェントジョブを停止しようとします。 |
| SynchronizeWithJob() |
サブスクリプションの同期のためにエージェントジョブを開始します。 |