MergeSynchronizationAgent Clase
Definición
Importante
Parte de la información hace referencia a la versión preliminar del producto, que puede haberse modificado sustancialmente antes de lanzar la versión definitiva. Microsoft no otorga ninguna garantía, explícita o implícita, con respecto a la información proporcionada aquí.
Proporciona la funcionalidad del Replication Agente de mezcla.
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
- Herencia
-
MergeSynchronizationAgent
- Atributos
- Implementaciones
Ejemplos
En el siguiente ejemplo, el Synchronize método se llama a la instancia de la MergeSynchronizationAgent clase a la que se accede desde la SynchronizationAgent propiedad para sincronizar la suscripción 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
En el siguiente ejemplo, se utiliza una instancia de la MergeSynchronizationAgent clase para sincronizar una suscripción de fusión. Debido a que la suscripción pull se creó usando un valor de false para CreateSyncAgentByDefault, deben proporcionarse propiedades adicionales.
// 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
Comentarios
La MergeSynchronizationAgent clase permite realizar las siguientes tareas de replicación:
Sincroniza suscripciones.
Especifica si solo la fase de subida, solo la de descarga o ambas fases se ejecutan durante la sincronización.
Valida que una suscripción tenga los datos esperados.
Especifica una carpeta de instantáneas diferente, desde la cual se pueda aplicar la instantánea inicial de una suscripción.
Constructores
| Nombre | Description |
|---|---|
| MergeSynchronizationAgent() |
Crea una instancia de la clase MergeSynchronizationAgent. |
Propiedades
| Nombre | Description |
|---|---|
| AlternateSynchronizationPartnerCollection |
Consigue a los socios alternativos de sincronización para una suscripción. |
| AltSnapshotFolder |
Obtiene o establece la carpeta de instantáneas alternativas para la suscripción. |
| ComErrorCollection |
Obtiene una colección de errores generados por el agente de replicación. |
| Distributor |
Obtiene o establece el nombre de la instancia de Microsoft SQL Server que actúa como distribuidor de la suscripción. |
| DistributorAddress |
Obtiene o establece la dirección de red que se utiliza para conectarse al Distribuidor cuando se especifica la DistributorNetwork propiedad. |
| DistributorEncryptedPassword |
Obtiene o establece la contraseña cifrada del distribuidor. |
| DistributorLogin |
Obtiene o establece el nombre de usuario que se usa al conectarse al distribuidor usando la autenticación de SQL Server. |
| DistributorNetwork |
Obtiene o establece el Net-Library cliente que se usa al conectarse al distribuidor. |
| DistributorPassword |
Establece la contraseña que se usa al conectarse al distribuidor usando la autenticación de SQL Server. |
| DistributorSecurityMode |
Obtiene o establece el modo de seguridad utilizado al conectarse al distribuidor. |
| DownloadGenerationsPerBatch |
Obtiene o establece el número de generaciones que se procesarán en un solo lote mientras se descarga los cambios desde el Publisher al Suscriptor. Una generación se define como un grupo lógico de cambios por artículo. |
| DynamicSnapshotLocation |
Obtiene o establece la ubicación de la instantánea particionada para este Suscriptor. |
| ExchangeType |
Obtiene o establece cómo se intercambian datos durante la sincronización. |
| FileTransferType |
Obtiene o establece cómo se transfieren los archivos de instantánea iniciales al Suscriptor. |
| HostName |
Obtiene o establece el valor que utiliza el Agente de mezcla cuando evalúa un filtro parametrizado que utiliza la función HOST_NAME. |
| InputMessageFile |
Obtiene o establece el archivo de mensaje de entrada. |
| InternetLogin |
Obtiene o establece el nombre de usuario que se utiliza con la sincronización web al conectarse al Publisher mediante autenticación por Internet. |
| InternetPassword |
Establece la contraseña de la InternetLogin propiedad que se usa con la sincronización web al conectarse al Publisher mediante autenticación por Internet. |
| InternetProxyLogin |
Obtiene o establece el nombre de usuario que se utiliza con la sincronización web al conectarse al servidor web mediante un servidor proxy de Internet. |
| InternetProxyPassword |
Establece la contraseña para el inicio de sesión que se utiliza con la sincronización web al conectarse al servidor web mediante un servidor proxy de Internet. |
| InternetProxyServer |
Obtiene o establece el nombre del servidor proxy de Internet que se utiliza con la sincronización web al conectarse al servidor web. |
| InternetSecurityMode |
Obtiene o establece el método de autenticación HTTP que se utiliza al conectarse al servidor web durante la sincronización web. |
| InternetTimeout |
Obtiene o establece el tiempo de espera HTTP al conectarse al servidor web. |
| InternetUrl |
Obtiene o establece la URL del servicio web configurado para la sincronización web. |
| LastUpdatedTime |
Obtiene la marca de tiempo de la última vez que ese agente de replicación sincronizó la suscripción. |
| LoginTimeout |
Obtiene o establece el número máximo de segundos para esperar a que se establezcan las conexiones. |
| MetadataRetentionCleanup |
Obtén o configura si limpiar metadatos. |
| Output |
Obtiene o establece el archivo de salida del agente. |
| OutputMessageFile |
Obtiene o establece el archivo de mensaje de entrada. |
| OutputVerboseLevel |
Obtiene o establece el nivel de detalle de la información que se escribe en el archivo de salida del agente. |
| ProfileName |
Obtiene o establece el nombre del perfil que utiliza el agente. |
| Publication |
Obtiene o establece el nombre de la publicación. |
| Publisher |
Obtiene o establece el nombre de la instancia de Microsoft SQL Server que es el Publisher de la suscripción. |
| PublisherAddress |
Obtiene o establece la dirección de red que se usa para conectarse al Publisher cuando se especifica la PublisherNetwork propiedad. |
| PublisherChanges |
Obtiene el número total de cambios en Publisher que se aplicaron al Suscriptor durante la última sincronización. |
| PublisherConflicts |
Obtiene el número total de conflictos que ocurrieron en el Publisher durante la última sincronización. |
| PublisherDatabase |
Obtiene o establece el nombre de la base de datos de publicaciones. |
| PublisherEncryptedPassword |
Obtiene o establece la contraseña cifrada por el editor. |
| PublisherFailoverPartner |
Obtiene o establece la instancia del socio de conmutación por fallo de SQL Server que participa en una sesión de espejo de base de datos con la base de datos de publicación. |
| PublisherLogin |
Obtiene o establece el nombre de usuario que se usa al conectarse al Publisher usando la autenticación de SQL Server. |
| PublisherNetwork |
Obtiene o establece el Net-Library cliente que se usa al conectarse al Publisher. |
| PublisherPassword |
Establece la contraseña que se usa al conectarse al Publisher mediante la autenticación de SQL Server. |
| PublisherSecurityMode |
Obtiene o establece el modo de seguridad que se usa al conectarse al Publisher. |
| QueryTimeout |
Obtiene o establece el número de segundos permitidos para que las consultas internas terminen. |
| SecureDistributorEncryptedPassword |
Obtiene o establece la contraseña cifrada del distribuidor seguro. |
| SecurePublisherEncryptedPassword |
Obtiene o establece la contraseña cifrada del editor seguro. |
| SecureSubscriberEncryptedPassword |
Obtiene o establece la contraseña cifrada segura del suscriptor. |
| Subscriber |
Obtiene o establece el nombre de la instancia de Microsoft SQL Server que es el Suscriptor. |
| SubscriberChanges |
Obtiene el número total de cambios de suscriptor que se aplicaron en el Publisher durante la última sincronización. |
| SubscriberConflicts |
Obtiene el número total de conflictos que ocurrieron en el Publisher durante la última sincronización. |
| SubscriberDatabase |
Obtiene o establece el nombre de la base de datos de suscripción. |
| SubscriberDatabasePath |
Obtiene o establece la ruta de la base de datos de suscriptores. |
| SubscriberDataSourceType |
Obtiene o establece el tipo de fuente de datos que se utiliza como Suscriptor. |
| SubscriberEncryptedPassword |
Obtiene o establece la contraseña cifrada del suscriptor. |
| SubscriberLogin |
Obtiene o establece el nombre de usuario que se utiliza al conectarse al Suscriptor mediante la autenticación de SQL Server. |
| SubscriberPassword |
Establece la contraseña que se usa al conectarse al Suscriptor mediante la autenticación de SQL Server. |
| SubscriberSecurityMode |
Obtiene o establece el modo de seguridad utilizado al conectarse al Suscriptor. |
| SubscriptionType |
Obtiene o determina si la suscripción es de empuje o de tirada. |
| SyncToAlternate |
Obtiene o establece si la sincronización es con un socio de sincronización alternativo. |
| UploadGenerationsPerBatch |
Obtiene o establece el número de generaciones que se procesarán en un solo lote mientras se suben los cambios del Suscriptor al Publisher. Una generación se define como un grupo lógico de cambios por artículo. |
| UseInteractiveResolver |
Obtiene o establece si el resolvedor interactivo se utiliza durante la conciliación. |
| UseWebSynchronization |
Obtiene o establece si se utiliza la sincronización web. |
| Validate |
Obtiene o establece si se realiza la validación de datos sobre los datos del suscriptor al final de la sincronización. |
| WorkingDirectory |
Obtiene o establece el directorio de trabajo desde el que se accede a los archivos snapshot cuando se usa FTP. |
Métodos
| Nombre | Description |
|---|---|
| Abort() |
Aborta la sincronización. |
| ClearAllTraceFlags() |
Borra todas las banderas de traza usadas por el agente de sincronización. |
| ClearTraceFlag(Int32) |
Elimina una bandera de rastreo. |
| Dispose() |
Libera los recursos no gestionados que utilizan MergeSynchronizationAgent. |
| Dispose(Boolean) |
Libera los recursos no gestionados que usa la MergeSynchronizationAgent clase y, opcionalmente, libera los recursos gestionados. |
| EnableTraceFlag(Int32) |
Activa el trazado de banderas. |
| Finalize() |
Finaliza el agente. |
| IsSnapshotRequired() |
Se conecta con el Publisher o Distribuidor y el Suscriptor para determinar si se aplicará una nueva instantánea durante la siguiente sincronización del agente. |
| ProcessMessagesAtPublisher() |
Procesa los mensajes en el editor. |
| ProcessMessagesAtSubscriber() |
Procesa los mensajes en el suscriptor. |
| Synchronize() |
Inicia el Agente de mezcla para sincronizar la suscripción. |
Eventos
| Nombre | Description |
|---|---|
| ComStatus |
Ocurre cuando el Agente de mezcla devuelve la información de estado de sincronización del Com. |
| Status |
Ocurre cuando el Agente de mezcla devuelve información de estado de sincronización. |
Se aplica a
Seguridad para subprocesos
Cualquier miembro público estático (compartido en Visual Basic) de este tipo es seguro para hilos. No se garantiza que los miembros de instancia sean seguros para el acceso concurrente.