ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / Managing databases / HFSQL / Managing replications / Log-based replication
  • Overview
  • Log-based replication by network
  • What is it?
  • The possible actions
  • How to replicate by network and through programming
  • Constraints and tips
  • Log-based replication via portable media
  • What is it?
  • The possible actions
  • Constraints and tips
  • Programmatically
  • WLanguage functions for managing log-based replication
  • Functions for managing log-based replication
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Log-based replication: Programming the log-based replication in WLanguage
HFSQL ClassicAvailable only with this kind of connection
Overview
Several WLangage functions allow you to include log-based replication in your application and to customize it. In this case, no external tool is required: the replication of data between your databases is managed by programming.
Two modes of log-based replication can be implemented through programming:
  • log-based replication by network (case of a laptop that connects to the company network on a regular basis).
  • log-based replication via portable media (case of remote sites that do not connect via a network).
Log-based replication by network

What is it?

Log-based replication by network corresponds to the operation performed to synchronize two databases accessible on the same network.
The most common example is a salesman who regularly connects to the company network via his laptop computer. The replication allows him to update the company database with the new orders entered during the week.
During this operation, the company database and the laptop database are accessible via network. The replication can be performed via network.

The possible actions

Log-based replication by network is used to perform:
  • a unidirectional replication:
    • from the master computer to the subscriber computers.
    • from the subscriber computers to the master computer.
  • a bidirectional replication, which means from the master computer to the subscriber computer (and conversely).

How to replicate by network and through programming

The following operations must be performed:
  1. Creating the master replica on the master computer (HCreateMasterReplica).
  2. Creating the subscriber replica on the subscriber computer (HCreateSubscriberReplica). The subscriber computer must have read/write access to the disk where the master application is installed (directory of data files).
  3. Using the master and subscriber applications.
  4. Synchronization (HSynchronizeReplica):
    • from the subscriber computer to the master computer (rplToMaster constant constant): the subscriber computer must have read/write rights on the disk where the master application is installed.
    • from the master computer to the subscriber computer (rplToSubscriber constant): the master computer must have read/write rights on the disk where the subscriber application is installed.
    • bidirectional (rplBidirectional constant): the master computer must have read/write rights on the disk where the subscriber application is installed and the subscriber computer must have read/write rights on the disk where the master application is installed.
Caution: This paragraph assumes that the necessary operations have been performed in the application analysis before installing the application on the different computers. For more details, see Log-based replication: Modifying the analysis.

Constraints and tips

  • When creating the subscriber replica, the computer where the subscriber replica is installed must have read/write access onto the directory where the master replica is installed.
  • To perform the log-based replication, the path of the data files to replicate can be identified by:
    • a drive letter. In this case, the two computers involved in the replication must use the same drive letter. For example, if the replication is started from the subscriber computer:
      • on the master computer, the directory of the data files is found on X,
      • on the subscriber computer, the letter X must be associated with the drive containing the data files of the master computer.
    • UNC paths
    • relative paths.
  • To manage log-based replication in an application, the table of log operations (JournalOpération.fic file) must be identical for all files in replication in the same analysis.
  • The files required by the replication (*.RPM and *.RPL files) should be saved in a RPL sub-directory of the application data files.
  • If the log process is used for the replication only, the log files can be located in the directory of application (or in a subdirectory).
  • If the log process is used to keep a backup of the files, these files should be located on a disk other than the one used for the data files (for better security).
Log-based replication via portable media

What is it?

Log-based replication via portable media corresponds to the operation performed to synchronize two databases not connected to each other.
The most common example corresponds to two sites that are geographically distant: a site in Montpellier and a site in Paris for example. The databases are updated on a regular basis via different media: transfer by FTP, diskette or CD ROM, ...

The possible actions

Log-based replication via portable media allows you to perform a unidirectional replication:
  • from the master computer to the subscriber computers
  • from the subscriber computers to the master computer

Constraints and tips

  • To manage log-based replication in an application, the table of log operations (JournalOpération.fic file) must be identical for all the files in replication in the same analysis.
  • The files required by the log-based replication (*.RPM and *.RPL files) should be saved in a RPL subdirectory of application data files.
  • If the log process is used for the replication only, the log files can be located in the directory of application (or in a subdirectory).
  • If the log process is used to keep a backup of the files, these files should be located on a disk other than the one used for the data files (for better security).

Programmatically

The following operations must be performed in order to synchronize the master computer with the subscriber computer:
  1. Creating:
    • the master replica on the master computer (HCreateMasterReplica).
    • the subscriber replica on the subscriber computer (HCreateSubscriberReplica). Each subscriber computer must be associated with a specific identifier. This identifier will be used during the synchronization.
      These two replicas can be created in the same directory (not recommended).
  2. Installing the file of subscriber replica on the subscriber computer. This file can be installed:
    • in the replication directory specified in the analysis (\RPL subdirectory of data files by default).
    • in another directory. In this case, the subscriber application must use HChangeRplDir to specify where to search for the file of the subscriber replica. Indeed, when the subscriber data file is opened, the RPL file is read in order to define the range of automatic identifiers used by the data file.
  3. Using the master and subscriber applications.
  4. On the subscriber computer, creating the movable replica (HCreateMovableReplica). A file with a WDZ extension is created by default. This file must be transmitted to the master computer.
  5. Synchronization on the master computer (HSynchronizeReplica). To perform this synchronization, you must specify:
    • the name and path of the movable replica on the master computer
    • the identifier of the subscriber replica (specified when creating the subscriber replica).
Caution: This paragraph assumes that the necessary operations have been performed in the application analysis before installing the application on the different computers. For more details, see Replication with WINDEV.
WLanguage functions for managing log-based replication

Functions for managing log-based replication

The following WLangage functions are used to manage log-based replication:
HChangeRplDirModifies the location for the description of subscriber replica (RPL file). This function must be used on the subscriber computer.
HCreateMasterReplicaCreates the description file of a master replica (*.RPM file).
HCreateMovableReplicaCreates a file that can be used to replicate the data from the current database to a remote database (for sending via email or diskette for example).
HCreateSubscriberReplicaCreates the description file of a subscriber replica (*.RPL file).
HInitSubscriberInitializes the range of automatic identifiers for the description file of subscriber replica (".RPL" extension).
HSetReplicationTemporarily disables (or re-enables) the replication. The replication is automatically managed by default.
HSynchronizeReplicaSynchronizes a master replica and a subscriber replica.
Minimum version required
  • Version 12
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 05/26/2022

Send a report | Local help