TransSynchronizationAgent クラス
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
Replication ディストリビューション エージェントの機能を提供します。
public ref class TransSynchronizationAgent : MarshalByRefObject, IDisposable, Microsoft::SqlServer::Replication::ITransSynchronizationAgent
[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("adeda98a-bdfc-4029-b6fb-991d6b468395")]
public class TransSynchronizationAgent : MarshalByRefObject, IDisposable, Microsoft.SqlServer.Replication.ITransSynchronizationAgent
[<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("adeda98a-bdfc-4029-b6fb-991d6b468395")>]
type TransSynchronizationAgent = class
inherit MarshalByRefObject
interface IDisposable
interface ITransSynchronizationAgent
Public Class TransSynchronizationAgent
Inherits MarshalByRefObject
Implements IDisposable, ITransSynchronizationAgent
- 継承
-
TransSynchronizationAgent
- 属性
- 実装
例
以下の例では、SynchronizeプロパティからアクセスされるTransSynchronizationAgentクラスのインスタンスでSynchronizationAgentメソッドが呼び出され、プッシュサブスクリプションを同期します。
// Define the server, publication, and database names.
string subscriberName = subscriberInstance;
string publisherName = publisherInstance;
string publicationName = "AdvWorksProductTran";
string subscriptionDbName = "AdventureWorks2012Replica";
string publicationDbName = "AdventureWorks2012";
// Create a connection to the Publisher.
ServerConnection conn = new ServerConnection(publisherName);
TransSubscription subscription;
try
{
// Connect to the Publisher.
conn.Connect();
// Define the push subscription.
subscription = new TransSubscription();
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 Distribution 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 = "AdvWorksProductTran"
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 TransSubscription
Try
' Connect to the Publisher.
conn.Connect()
' Define the push subscription.
subscription = New TransSubscription()
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 Distribution 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.")
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
注釈
TransSynchronizationAgentクラスは、サブスクリプションをトランザクションやスナップショット出版物にプログラム的に同期する機能をサポートしています。
コンストラクター
| 名前 | 説明 |
|---|---|
| TransSynchronizationAgent() |
TransSynchronizationAgent クラスのインスタンスを作成します。 |
プロパティ
| 名前 | 説明 |
|---|---|
| AltSnapshotFolder |
サブスクリプション用の代替スナップショットフォルダを取得したり設定したりします。 |
| ComErrorCollection |
レプリケーションエージェントによって生成されるエラーの集合を取得します。 |
| Distributor |
サブスクリプションのディストリビューターとして動作するMicrosoft SQL Serverのインスタンス名を取得するか設定します。 |
| DistributorAddress |
DistributorNetworkプロパティが指定された際に、ディストリビューターに接続するために使われるネットワークアドレスを取得したり設定したりします。 |
| DistributorEncryptedPassword |
SQL Server認証を用いて、ディストリビューターに接続する際に使われる暗号化パスワードを取得したり設定したりします。 |
| DistributorLogin |
SQL Server認証を用いて、ディストリビューターに接続する際に使われるログイン名を取得したり設定したりします。 |
| DistributorNetwork |
ディストリビューターに接続する際に使うクライアント Net-Library を取得したり設定したりします。 |
| DistributorPassword |
SQL Server認証を用いてディストリビューターに接続する際に使われるパスワードを取得したり設定したりします。 |
| DistributorSecurityMode |
ディストリビューターに接続する際に使われるセキュリティモードを取得または設定します。 |
| DtsPackageFileName |
Microsoft SQL Server 2000のデータ変換サービス(DTS)パッケージの名前と経路を取得し、サブスクライバーに適用する前にコマンドの行セットを変換します。 |
| DtsPackagePassword |
DtsPackageFileNameプロパティで指定されたMicrosoft SQL Server 2000データ変換サービス(DTS)パッケージにアクセスするために使用された所有者パスワードを取得したり設定したりします。 |
| FileTransferType |
初期のスナップショットファイルをサブスクライバーにどのように転送するかを取得または設定します。 |
| HostName |
ホスト名を取得するか設定します。 |
| LastUpdatedTime |
レプリケーションエージェントが最後にサブスクリプションを同期した時刻のタイムスタンプを取得します。 |
| LoginTimeout |
接続が確立されるまで待つ最大秒数を取得または設定します。 |
| MaxDeliveredTransactions |
単一エージェント実行中にサブスクライバーに適用される最大トランザクション数を取得または設定します。 |
| Output |
エージェント出力ファイルのファイル名とパスを取得したり設定したりします。 |
| OutputVerboseLevel |
ディストリビューション エージェントがエージェントの出力ファイルに記録する情報量を取得または設定します。 |
| ProfileName |
エージェントが使用するプロファイルの名前を取得するか設定します。 |
| Publication |
出版物の名前を取得するか設定します。 |
| Publisher |
サブスクリプションのPublisherであるMicrosoft SQL Serverのインスタンス名を取得したり設定したりします。 |
| PublisherDatabase |
出版物データベースの名前を取得するか設定します。 |
| QueryTimeout |
内部クエリが完了する秒数を取得または設定します。 |
| SecureDistributorEncryptedPassword |
配布者のために安全な暗号化パスワードを取得するか設定します。 |
| SecureSubscriberEncryptedPassword |
加入者のために安全な暗号化パスワードを取得するか設定します。 |
| SkipErrors |
このエージェントがスキップすべきエラー番号のコロン分離リストを取得したり設定したりします。 |
| Subscriber |
加入者であるMicrosoft SQL Serverのインスタンス名を取得したり設定したりします。 |
| SubscriberDatabase |
サブスクリプションデータベースの名前を取得するか設定します。 |
| SubscriberDatabasePath |
加入者のデータベースパスを取得するか設定します。 |
| SubscriberDataSourceType |
購読者として使用されるデータソースの種類を取得するか設定します。 |
| SubscriberEncryptedPassword |
加入者の暗号化パスワードを取得または設定します。 |
| SubscriberLogin |
SQL Server認証を使って加入者に接続する際に使われるログイン名を取得したり設定したりします。 |
| SubscriberPassword |
SQL Server認証を使って加入者に接続する際に使うパスワードを取得したり設定したりします。 |
| SubscriberSecurityMode |
パブリッシャーに接続する際に使われるセキュリティモードを取得したり設定したりします。 |
| SubscriptionType |
サブスクリプションがプッシュかプルかを把握するかを決めます。 |
| UndeliveredCommands |
未配信のコマンド数を取得します。 |
| UndeliveredTransactions |
未配達取引数を取得します。 |
| UseInProcLoader |
スナップショットファイルをサブスクライバーに適用する際にBULK INSERTコマンドを使うかどうかを示す値を取得または設定します。 |
| WorkingDirectory |
ファイル転送プロトコル(FTP)を使用する際にスナップショットファイルにアクセスする作業ディレクトリを取得したり設定したりします。 |
メソッド
| 名前 | 説明 |
|---|---|
| Abort() |
TransSynchronizationAgent作戦を中止する。 |
| Dispose() |
TransSynchronizationAgent クラスの現在のインスタンスで使用されているすべてのリソースを解放します。 |
| Dispose(Boolean) |
TransSynchronizationAgent クラスによって使用されるすべてのリソースを解放します。 |
| Finalize() |
TransSynchronizationAgentを最終決定します。 |
| IsSnapshotRequired() |
ディストリビューターと加入者に接続し、次のエージェント同期時に新しいスナップショットが適用されるかどうかを判断します。 |
| Synchronize() |
ディストリビューション エージェントを起動してサブスクリプションを同期します。 |
イベント
| 名前 | 説明 |
|---|---|
| ComStatus |
ディストリビューション エージェントが同期通信ステータス情報を返すときに発生します。 |
| Status |
ディストリビューション エージェントが同期状態情報を返すときに発生します。 |
適用対象
スレッド セーフ
TransSynchronizationAgentクラスはマルチスレッドアパートメントをサポートしていません。 アプリケーションの主なエントリポイントであるメソッドに [STAThread] 属性を宣言することで、シングルスレッドのアパートメントを指定できます。 これはMicrosoft Visual Studioを使って作成されたMicrosoft Windowsベースのアプリケーションのデフォルトです。