Bagikan melalui


MergeSynchronizationAgent Kelas

Definisi

Menyediakan fungsionalitas Agen Penggabungan Replikasi.

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
Warisan
MergeSynchronizationAgent
Atribut
Penerapan

Contoh

Dalam contoh berikut, Synchronize metode ini dipanggil pada instans MergeSynchronizationAgent kelas yang diakses dari SynchronizationAgent properti untuk menyinkronkan langganan push.

// 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

Dalam contoh berikut, instans MergeSynchronizationAgent kelas digunakan untuk menyinkronkan langganan gabungan. Karena langganan penarikan dibuat dengan menggunakan nilai false untuk CreateSyncAgentByDefault, properti tambahan harus disediakan.

// 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

Keterangan

Kelas MergeSynchronizationAgent ini mendukung kemampuan untuk melakukan tugas replikasi berikut:

  • Menyinkronkan langganan.

  • Tentukan apakah hanya fase unggahan, hanya fase pengunduhan, atau kedua fase yang dijalankan selama sinkronisasi.

  • Validasi bahwa langganan memiliki data yang diharapkan.

  • Tentukan folder rekam jepret yang berbeda, tempat rekam jepret awal untuk langganan dapat diterapkan.

Konstruktor

MergeSynchronizationAgent()

Membuat instans MergeSynchronizationAgent kelas .

Properti

AlternateSynchronizationPartnerCollection

Mendapatkan mitra sinkronisasi alternatif untuk langganan.

AltSnapshotFolder

Mendapatkan atau mengatur folder rekam jepret alternatif untuk langganan.

ComErrorCollection

Mendapatkan kumpulan kesalahan yang dihasilkan oleh agen replikasi.

Distributor

Mendapatkan atau menetapkan nama instans Microsoft SQL Server yang bertindak sebagai Distributor untuk langganan.

DistributorAddress

Mendapatkan atau mengatur alamat jaringan yang digunakan untuk menyambungkan ke Distributor saat DistributorNetwork properti ditentukan.

DistributorEncryptedPassword

Mendapatkan atau mengatur kata sandi terenkripsi distributor.

DistributorLogin

Mendapatkan atau mengatur nama masuk yang digunakan saat menyambungkan ke Distributor menggunakan Autentikasi SQL Server.

DistributorNetwork

Mendapatkan atau mengatur Net-Library klien yang digunakan saat menyambungkan ke Distributor.

DistributorPassword

Mengatur kata sandi yang digunakan saat menyambungkan ke Distributor menggunakan Autentikasi SQL Server.

DistributorSecurityMode

Mendapatkan atau mengatur mode keamanan yang digunakan saat menyambungkan ke Distributor.

DownloadGenerationsPerBatch

Mendapatkan atau mengatur jumlah generasi yang akan diproses dalam satu batch saat mengunduh perubahan dari Penerbit ke Pelanggan. Generasi didefinisikan sebagai grup perubahan logis per artikel.

DynamicSnapshotLocation

Mendapatkan atau mengatur lokasi rekam jepret yang dipartisi untuk Pelanggan ini.

ExchangeType

Mendapatkan atau mengatur bagaimana data dipertukarkan selama sinkronisasi.

FileTransferType

Mendapatkan atau mengatur bagaimana file rekam jepret awal ditransfer ke Pelanggan.

HostName

Mendapatkan atau mengatur nilai yang digunakan oleh Agen Penggabungan saat mengevaluasi filter berparameter yang menggunakan fungsi HOST_NAME .

InputMessageFile

Mendapatkan atau mengatur file pesan input.

InternetLogin

Mendapatkan atau mengatur nama masuk yang digunakan dengan sinkronisasi Web saat menyambungkan ke Publisher dengan menggunakan autentikasi Internet.

InternetPassword

Menyetel kata sandi untuk InternetLogin properti yang digunakan dengan sinkronisasi Web saat menyambungkan ke Publisher dengan menggunakan autentikasi Internet.

InternetProxyLogin

Mendapatkan atau mengatur nama masuk yang digunakan dengan sinkronisasi Web saat menyambungkan ke server Web dengan menggunakan server proksi Internet.

InternetProxyPassword

Menyetel kata sandi untuk log masuk yang digunakan dengan sinkronisasi Web saat menyambungkan ke server Web dengan menggunakan server proksi Internet.

InternetProxyServer

Mendapatkan atau mengatur nama server proksi Internet yang digunakan dengan sinkronisasi Web saat menyambungkan ke server Web.

InternetSecurityMode

Mendapatkan atau mengatur metode autentikasi HTTP yang digunakan saat menyambungkan ke server Web selama sinkronisasi Web.

InternetTimeout

Mendapatkan atau mengatur batas waktu HTTP saat menyambungkan ke server Web.

InternetUrl

Mendapatkan atau mengatur URL layanan Web yang dikonfigurasi untuk sinkronisasi Web.

LastUpdatedTime

Mendapatkan tanda waktu terakhir kali agen replikasi tersebut menyinkronkan langganan.

LoginTimeout

Mendapatkan atau mengatur jumlah detik maksimum untuk menunggu koneksi dibuat.

MetadataRetentionCleanup

Mendapatkan atau mengatur apakah akan membersihkan metadata.

Output

Mendapatkan atau mengatur file output agen.

OutputMessageFile

Mendapatkan atau mengatur file pesan input.

OutputVerboseLevel

Mendapatkan atau mengatur tingkat detail informasi yang ditulis ke file output agen.

ProfileName

Mendapatkan atau mengatur nama profil yang digunakan oleh agen.

Publication

Mendapatkan atau mengatur nama publikasi.

Publisher

Mendapatkan atau mengatur nama instans Microsoft SQL Server yang merupakan Penerbit untuk langganan.

PublisherAddress

Mendapatkan atau mengatur alamat jaringan yang digunakan untuk menyambungkan ke Publisher saat PublisherNetwork properti ditentukan.

PublisherChanges

Mendapatkan jumlah total perubahan Penerbit yang diterapkan di Pelanggan selama sinkronisasi terakhir.

PublisherConflicts

Mendapatkan jumlah total konflik yang terjadi di Publisher selama sinkronisasi terakhir.

PublisherDatabase

Mendapatkan atau mengatur nama database publikasi.

PublisherEncryptedPassword

Mendapatkan atau mengatur kata sandi terenkripsi penerbit.

PublisherFailoverPartner

Mendapatkan atau mengatur instans mitra failover SQL Server yang berpartisipasi dalam sesi pencerminan database dengan database publikasi.

PublisherLogin

Mendapatkan atau mengatur nama masuk yang digunakan saat menyambungkan ke Penerbit dengan menggunakan Autentikasi SQL Server.

PublisherNetwork

Mendapatkan atau mengatur Net-Library klien yang digunakan saat menyambungkan ke Publisher.

PublisherPassword

Menyetel kata sandi yang digunakan saat menyambungkan ke Penerbit dengan menggunakan Autentikasi SQL Server.

PublisherSecurityMode

Mendapatkan atau mengatur mode keamanan yang digunakan saat menyambungkan ke Publisher.

QueryTimeout

Mendapatkan atau mengatur jumlah detik yang diizinkan untuk menyelesaikan kueri internal.

SecureDistributorEncryptedPassword

Mendapatkan atau mengatur kata sandi terenkripsi distributor aman.

SecurePublisherEncryptedPassword

Mendapatkan atau mengatur kata sandi terenkripsi penerbit aman.

SecureSubscriberEncryptedPassword

Mendapatkan atau mengatur kata sandi terenkripsi pelanggan yang aman.

Subscriber

Mendapatkan atau menetapkan nama instans Microsoft SQL Server yang merupakan Pelanggan.

SubscriberChanges

Mendapatkan jumlah total perubahan Pelanggan yang diterapkan di Penerbit selama sinkronisasi terakhir.

SubscriberConflicts

Mendapatkan jumlah total konflik yang terjadi di Publisher selama sinkronisasi terakhir.

SubscriberDatabase

Mendapatkan atau mengatur nama database langganan.

SubscriberDatabasePath

Mendapatkan atau mengatur jalur database pelanggan.

SubscriberDataSourceType

Mendapatkan atau mengatur jenis sumber data yang digunakan sebagai Pelanggan.

SubscriberEncryptedPassword

Mendapatkan atau mengatur kata sandi terenkripsi pelanggan.

SubscriberLogin

Mendapatkan atau mengatur nama login yang digunakan yaitu saat menyambungkan ke Pelanggan dengan menggunakan Autentikasi SQL Server.

SubscriberPassword

Mengatur kata sandi yang digunakan saat menyambungkan ke Pelanggan dengan menggunakan Autentikasi SQL Server.

SubscriberSecurityMode

Mendapatkan atau mengatur mode keamanan yang digunakan saat menyambungkan ke Pelanggan.

SubscriptionType

Mendapatkan atau mengatur apakah langganan adalah langganan pendorongan atau penarikan.

SyncToAlternate

Mendapatkan atau mengatur apakah sinkronisasi adalah ke mitra sinkronisasi alternatif.

UploadGenerationsPerBatch

Mendapatkan atau mengatur jumlah generasi yang akan diproses dalam satu batch saat mengunggah perubahan dari Pelanggan ke Penerbit. Generasi didefinisikan sebagai grup perubahan logis per artikel.

UseInteractiveResolver

Mendapatkan atau mengatur apakah resolver interaktif digunakan selama rekonsiliasi.

UseWebSynchronization

Mendapatkan atau menyetel apakah sinkronisasi Web digunakan.

Validate

Mendapatkan atau mengatur apakah validasi data dilakukan pada data Pelanggan di akhir sinkronisasi.

WorkingDirectory

Mendapatkan atau mengatur direktori kerja tempat file rekam jepret diakses saat FTP digunakan.

Metode

Abort()

Membatalkan sinkronisasi.

ClearAllTraceFlags()

Menghapus semua bendera pelacakan yang digunakan oleh agen sinkronisasi.

ClearTraceFlag(Int32)

Menghapus bendera pelacakan.

Dispose()

Merilis sumber daya tidak terkelola yang digunakan oleh MergeSynchronizationAgent.

Dispose(Boolean)

Merilis sumber daya tidak terkelola yang digunakan oleh MergeSynchronizationAgent kelas dan secara opsional merilis sumber daya terkelola.

EnableTraceFlag(Int32)

Mengaktifkan pelacakan bendera.

Finalize()

Menyelesaikan agen.

IsSnapshotRequired()

Menyambungkan ke Penerbit atau Distributor dan Pelanggan untuk menentukan apakah rekam jepret baru akan diterapkan selama sinkronisasi agen berikutnya.

ProcessMessagesAtPublisher()

Memproses pesan di penerbit.

ProcessMessagesAtSubscriber()

Memproses pesan di pelanggan.

Synchronize()

Memulai Agen Penggabungan untuk menyinkronkan langganan.

Acara

ComStatus

Terjadi ketika Agen Penggabungan mengembalikan informasi status Com sinkronisasi.

Status

Terjadi ketika Agen Penggabungan mengembalikan informasi status sinkronisasi.

Berlaku untuk

Keamanan Thread

Setiap anggota statis publik (Dibagikan dalam Visual Basic) jenis ini aman untuk utas. Setiap anggota instans tidak dijamin aman untuk utas.