MergeSynchronizationAgent クラス
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
Replication マージ エージェントの機能を提供します。
public ref class MergeSynchronizationAgent : MarshalByRefObject, IDisposable, Microsoft::SqlServer::Replication::IMergeSynchronizationAgent
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)]
[System.Runtime.InteropServices.ComSourceInterfaces(typeof(Microsoft.SqlServer.Replication.IComStatusEvent))]
[System.Runtime.InteropServices.ComVisible(true)]
[System.Runtime.InteropServices.Guid("ee5ee47e-6d29-448f-b2d2-f8e632db336a")]
public class MergeSynchronizationAgent : MarshalByRefObject, IDisposable, Microsoft.SqlServer.Replication.IMergeSynchronizationAgent
[<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)>]
[<System.Runtime.InteropServices.ComSourceInterfaces(typeof(Microsoft.SqlServer.Replication.IComStatusEvent))>]
[<System.Runtime.InteropServices.ComVisible(true)>]
[<System.Runtime.InteropServices.Guid("ee5ee47e-6d29-448f-b2d2-f8e632db336a")>]
type MergeSynchronizationAgent = class
inherit MarshalByRefObject
interface IDisposable
interface IMergeSynchronizationAgent
Public Class MergeSynchronizationAgent
Inherits MarshalByRefObject
Implements IDisposable, IMergeSynchronizationAgent
- 継承
-
MergeSynchronizationAgent
- 属性
- 実装
例
以下の例では、SynchronizationAgentプロパティからアクセスされるMergeSynchronizationAgentクラスのインスタンスでSynchronizeメソッドが呼び出され、プッシュサブスクリプションを同期します。
// 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
以下の例では、 MergeSynchronizationAgent クラスのインスタンスを使ってマージサブスクリプションを同期します。 プルサブスクリプションはCreateSyncAgentByDefaultの値としてfalseを用いて作成されたため、追加のプロパティを供給する必要があります。
// 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
注釈
MergeSynchronizationAgentクラスは以下のレプリケーションタスクを実行する能力をサポートしています:
サブスクリプションの同期。
同期中にアップロードフェーズのみ、ダウンロードフェーズのみ、または両方のフェーズを実行するかを指定します。
サブスクリプションが期待されるデータを持っているか確認してください。
サブスクリプションの最初のスナップショットを適用できる別のスナップショットフォルダを指定します。
コンストラクター
| 名前 | 説明 |
|---|---|
| MergeSynchronizationAgent() |
MergeSynchronizationAgent クラスのインスタンスを作成します。 |
プロパティ
| 名前 | 説明 |
|---|---|
| AlternateSynchronizationPartnerCollection |
サブスクリプションの代替同期パートナーを手に入れます。 |
| AltSnapshotFolder |
サブスクリプション用の代替スナップショットフォルダを取得したり設定したりします。 |
| ComErrorCollection |
複製エージェントによって生成されたエラーの集合を取得します。 |
| Distributor |
サブスクリプションのディストリビューターとして動作するMicrosoft SQL Serverのインスタンス名を取得するか設定します。 |
| DistributorAddress |
DistributorNetworkプロパティが指定された際に、ディストリビュータに接続するために使われるネットワークアドレスを取得したり設定したりします。 |
| DistributorEncryptedPassword |
ディストリビューターの暗号化パスワードを取得するか設定します。 |
| DistributorLogin |
SQL Server認証でディストリビューターに接続する際に使われるログイン名を取得したり設定したりします。 |
| DistributorNetwork |
ディストリビューターに接続する際に使うクライアント Net-Library を取得したり設定したりします。 |
| DistributorPassword |
SQL Server認証を使ってディストリビューターに接続する際に使われるパスワードを設定します。 |
| DistributorSecurityMode |
ディストリビューターに接続する際に使われるセキュリティモードを取得または設定します。 |
| DownloadGenerationsPerBatch |
変更をPublisherからSubscriberにダウンロードしながら、1回のバッチで処理する世代数を取得または設定します。 生成結果は、アーティクルごとに変更の論理グループとして定義されます。 |
| DynamicSnapshotLocation |
このサブスクライバーのパーティション分割スナップショットの位置を取得したり設定したりします。 |
| ExchangeType |
同期中のデータの交換方法を取得または設定します。 |
| FileTransferType |
初期のスナップショットファイルをサブスクライバーにどのように転送するかを取得または設定します。 |
| HostName |
パラメータ化されたフィルターを評価する際に使う値を取得または設定します。マージ エージェント HOST_NAME関数を使用します。 |
| InputMessageFile |
入力メッセージファイルを取得または設定します。 |
| InternetLogin |
インターネット認証を使ってPublisherに接続する際に使われるログイン名を取得したり設定したりします。 |
| InternetPassword |
インターネット認証を用いてPublisherに接続する際に使われるInternetLoginプロパティのパスワードを設定します。 |
| InternetProxyLogin |
インターネットプロキシサーバーを使ってウェブサーバーに接続する際に使用されるログイン名を取得したり設定したりします。 |
| InternetProxyPassword |
インターネットプロキシサーバーを使ってウェブサーバーに接続する際に使用するログインパスワードを設定します。 |
| InternetProxyServer |
ウェブサーバーに接続する際に使われるインターネットプロキシサーバーの名前を取得したり設定したりします。 |
| InternetSecurityMode |
ウェブ同期時にWebサーバーに接続する際に使われるHTTP認証方法を取得したり設定したりします。 |
| InternetTimeout |
Webサーバーに接続する際にHTTPタイムアウトを取得または設定します。 |
| InternetUrl |
ウェブ同期用に設定されたWebサービスのURLを取得したり設定したりします。 |
| LastUpdatedTime |
レプリケーションエージェントが最後にサブスクリプションを同期した時刻のタイムスタンプを取得します。 |
| LoginTimeout |
接続が確立されるまで待つ最大秒数を取得または設定します。 |
| MetadataRetentionCleanup |
メタデータをクリーンアップするか設定するか。 |
| Output |
エージェント出力ファイルを取得または設定します。 |
| OutputMessageFile |
入力メッセージファイルを取得または設定します。 |
| OutputVerboseLevel |
エージェント出力ファイルに書き込まれる情報の詳細レベルを取得したり設定したりします。 |
| ProfileName |
エージェントが使用するプロファイルの名前を取得するか設定します。 |
| Publication |
出版物の名前を取得するか設定します。 |
| Publisher |
サブスクリプションのPublisherであるMicrosoft SQL Serverのインスタンス名を取得したり設定したりします。 |
| PublisherAddress |
PublisherNetworkプロパティが指定された際に、Publisherに接続するために使われるネットワークアドレスを取得したり設定したりします。 |
| PublisherChanges |
前回の同期時にサブスクライバーに適用された合計のPublisher変更数を取得します。 |
| PublisherConflicts |
前回の同期時にPublisherで発生した競合の合計数を取得します。 |
| PublisherDatabase |
出版物データベースの名前を取得するか設定します。 |
| PublisherEncryptedPassword |
出版社の暗号化パスワードを取得したり設定したりします。 |
| PublisherFailoverPartner |
公開データベースとミラーリングセッションに参加しているフェイルオーバーパートナーSQL Serverのインスタンスを取得します。 |
| PublisherLogin |
SQL Server認証を使って、Publisherに接続する際に使われるログイン名を取得したり設定したりします。 |
| PublisherNetwork |
接続時に使うクライアント Net-Library を取得したり設定したりしますPublisher。 |
| PublisherPassword |
SQL Server認証を用いてPublisherに接続する際に使われるパスワードを設定します。 |
| PublisherSecurityMode |
Publisherに接続する際に使われるセキュリティモードを取得または設定します。 |
| QueryTimeout |
内部クエリが完了するために許される秒数を取得または設定します。 |
| SecureDistributorEncryptedPassword |
安全なディストリビューターの暗号化パスワードを取得するか設定します。 |
| SecurePublisherEncryptedPassword |
安全なパブリッシャー暗号化パスワードを取得したり設定したりします。 |
| SecureSubscriberEncryptedPassword |
安全な加入者パスワードを取得または設定します。 |
| Subscriber |
サブスクライバーであるMicrosoft SQL Serverのインスタンス名を取得したり設定したりします。 |
| SubscriberChanges |
前回の同期時にPublisherに適用された加入者の変更総数を取得します。 |
| SubscriberConflicts |
前回の同期時にPublisherで発生した競合の合計数を取得します。 |
| SubscriberDatabase |
サブスクリプションデータベースの名前を取得するか設定します。 |
| SubscriberDatabasePath |
加入者データベースのパスを取得するか設定します。 |
| SubscriberDataSourceType |
サブスクライバーとして使用されるデータソースの種類を取得するか設定します。 |
| SubscriberEncryptedPassword |
加入者の暗号化パスワードを取得したり設定したりします。 |
| SubscriberLogin |
SQL Server認証を使って加入者に接続する際に使用されるログイン名を取得したり設定したりします。 |
| SubscriberPassword |
SQL Server認証を用いて加入者に接続する際に使われるパスワードを設定します。 |
| SubscriberSecurityMode |
加入者に接続する際に使われるセキュリティモードを取得または設定します。 |
| SubscriptionType |
サブスクリプションがプッシュかプルかを把握するかを決めます。 |
| SyncToAlternate |
同期が別の同期パートナーに割り当てられるかどうかを取得または設定します。 |
| UploadGenerationsPerBatch |
SubscriberからPublisherへの変更をアップロードする際、1回のバッチで処理する世代数を取得または設定します。 生成結果は、アーティクルごとに変更の論理グループとして定義されます。 |
| UseInteractiveResolver |
調整時にインタラクティブリゾルバを使用するかどうかをゲットまたはセットします。 |
| UseWebSynchronization |
Web同期が使用されるかどうかを取得または設定します。 |
| Validate |
同期終了時にサブスクライバーデータに対してデータ検証が行われるかどうかを取得または設定します。 |
| WorkingDirectory |
FTP使用時にスナップショットファイルにアクセスする作業ディレクトリを取得したり設定したりします。 |
メソッド
| 名前 | 説明 |
|---|---|
| Abort() |
同期を中止します。 |
| ClearAllTraceFlags() |
同期エージェントが使用するすべてのトレースフラグをクリアします。 |
| ClearTraceFlag(Int32) |
トレースフラグが解除されます。 |
| Dispose() |
MergeSynchronizationAgentが使用している管理されていないリソースを解放します。 |
| Dispose(Boolean) |
クラスで使用されている管理されていないリソース MergeSynchronizationAgent 解放し、オプションで管理されたリソースも解放します。 |
| EnableTraceFlag(Int32) |
旗のトレースを可能にします。 |
| Finalize() |
エージェントを最終決定する。 |
| IsSnapshotRequired() |
PublisherまたはDistributorおよびSubscriberに接続し、次のエージェント同期時に新しいスナップショットが適用されるかどうかを判断します。 |
| ProcessMessagesAtPublisher() |
メッセージをパブリッシャーで処理します。 |
| ProcessMessagesAtSubscriber() |
サブスクライバーでメッセージを処理します。 |
| Synchronize() |
サブスクリプションを同期するためにマージ エージェントを起動します。 |
イベント
| 名前 | 説明 |
|---|---|
| ComStatus |
マージ エージェントが同期Comの状態情報を返すときに発生します。 |
| Status |
マージ エージェントが同期状態情報を返すときに発生します。 |
適用対象
スレッド セーフ
このタイプのパブリックスタティック(Visual Basicで共有)メンバーはスレッド安全です。 インスタンス メンバーがスレッド セーフであるとは限りません。