Developer Guide |
|
User-Defined Extensions for Replication |
|
Audience: |
Developers and Architects |
Subject: |
Extending the Replication Agent with user-written functions to process data as it is accessed to handle conflict resolution, data transformation, and other specialized use cases |
Copyright: |
© Copyright 2024, FairCom Corporation. All rights reserved. For full information, see the FairCom Copyright Notice. |
This document describes using the Replication Extension Library with the original Replication Agent. The Extension Library can be also used with the newer Replication Manager. Contact FairCom for procedures.
FairCom replication supports loading a user-defined external library that can perform customized actions when processing replication operations. The library contains functions that are called when certain predefined events occur. This feature allows a software developer to customize the Replication Agent's behavior to support capabilities such as:
At their core, replication solutions need to copy data from a source server to a target server for the purpose of providing a failover server, maintaining backup copies, or creating an environment for testing or reporting. A foremost consideration is detecting and resolving conflicts between the data on the source and target servers. The Replication Agent is able to provide basic default handling of conflicts; however, many situations require adherence to individual corporate procedures based on proprietary business logic. The Extension Library allows developers to provide specialized logic to handle these situations according to your corporate policies.
Closely related to conflict detection, some replication environments must accommodate replication between non-identical datastores. For example, it may sometimes be necessary to replicate between databases with different schemas. The Extension Library can be used to provide functions that transform the source data to comply with the schema of the target data.
For example, suppose a replicated server is taken offline and a schema upgrade is performed on it. Because it now has a newer schema than the other replicated servers, the Extension Library could transform the data structure from the original server to the upgraded server. Note, be sure to also consider the use of FairCom’s new Hot Alter Table logic for helping to solve this scenario. See the Hot Alter Table documentation for specifics.
In the example above, an alternative strategy could be to selectively replicate to the updated server. In this case, the Extension Library could be used to filter out the data that should not be replicated.
When replicating to a third-party database, the Extension Library could be used to translate replication operations into inserts and updates to be applied to the third-party database.
The Replication Agent extensions are provided by an application developer within an SDK framework in an external library loaded by the Replication Agent at runtime. When a user-defined extension library is used, the Replication Agent calls a function in the external library for each operation that it reads from the source server. The function can modify the operation values, or take custom actions, and it can indicate to the agent what action to take for that operation.
To use this feature, the developer needs access to FairCom DB Professional and to a development environment that supports writing and compiling C code into a DLL or shared library.