Running the Sample Environment on Windows
In order to see the replication happening use SQL Server Management Studio to connect to the SqlReplicationIoHooks database and display the list of tables in the database - there aren't any at the moment. Run the replicator menu application by ensuring that replicator.vpj is the current project, opening the ReplicatorMenu source file, then selecting "Build > Execute" from the menu.
Start the replicator process by selecting the "SR" option; you will see it start in a different window. You should see some messages, including:
SQL Replicator Log
Processing interval is 2 seconds
Connecting to database...
Maximum cursors: 128
Maximum columns: 254
--- Processing instructions ------------------
Next, pick the "M" option to start the employee maintenance program; again you will see it start in a new window. Enter employee number 1 to display that record, then select field number 1 and enter a new value for the employees fist name. Save the change by typing E to exit, then Y to confirm the change.
This will record an update operation in the replication servers transaction log. Within a few seconds the replicator process should pick up the change, realize there is an update to the database, and try to replicate the change. The first time this happens it will realize that the EMPLOYEE table doesn't exist in the database, so it should create the table, and then initiate a full load of the table from the ISAM file. You should see replicator messages similar to this:
First instruction checks for table EMPLOYEE
- Opening associated data file
- File opened
- Checking if table exists
- Table not found!
- Creating table
- Table created
- Bulk load starting at YYYY-MM-DD HH:MM:SS
- Bulk load complete at YYYY-MM-DD HH:MM:SS
- Adding indexes
- Indexes added
- Key 0 will be used to synchronize changes
Update row in table EMPLOYEE
- Key: 000001
- Row updated
Check SQL Server Management studio, is the table and data there? If not then you probably got error messages from the replicator and need to debug the environment.
From now on, as you create, amend and delete employee records, those changes should be replicated to the EMPLOYEE table in SQL server. The example replicator goes to sleep for two seconds if there is nothing to do, so you should see any changes within that time frame. If you are sitting looking at the table in Management studio however, the table is not automatically refreshed, you you'll have to refresh it manually each time you want to see a change.
The replicator process would generally be run as a Windows service or detached process, and can be controlled by putting instructions into it's ISAM file. There are various options in the replicator menu to do this. For example, to stop the replicator, select the "S" option.
Running Replicator as a Windows Service
The replicator can be registered and started as a Windows Service, via the dbssvc.exe service runtime. An example of doing so can be round in the batch file RegisterReplicatorService.bat, and an example of un-registering the service can be found in UnregisterReplicatorService.bat.
Once registered the service may be stopped and started via the Windows Services application or via shell commands, e.g.:
net start SynergyReplicator
net stop SynergyReplicator
The connect string used in the example command assumes a SQL server database named SqlReplicationIoHooks running on the local system, and Windows Authentication is used to authenticate the user. The service that is registered by dbssvc will run under the context of the Local System account, so you must authorize that account to access the SQL Server database. To do this, use SQL Server Enterprise Manager:
1.Go to Secutiry / Logins
2.Right-click NT AUTHORITY\SYSTEM and select Properties
3.Go to "User Mapping" and check the Map check-box next to your database, and then check the "db_owner" role.
4.Click OK to save the change
You must also ensure that the EXE logical name is specified in a way that it is available to the replicator when it runs under the context of the Local System account. There are a couple of ways of doing that:
•Use the Windows System Properties dialog to set EXE as an actual system wide environment variable.
•Set the value in the [replicator] section of your synergy.ini file like this:
Due to a bug (related to the maximum length of a windows command line) in the 10.3.3c and earlier versions of the dbssvc.exe runtime, if you wish to register replicator as a windows service in conjunction with using the command-line configuration options, you must be running Synergy 10.3.3c with the HotFix dated July 31st 2017 or later, or with a later version of Synergy/DE. You can obtain the required hot-fix from Synergex Support. As an alternative, use the environment variables method of configuring the service (in synergy.ini as shown above).