Replication Setup
A common scenario is to sync a set of tables while excluding some tables from being synced. If tables are named with common conventions, a wildcard character can match a set of tables. For example, a set of customer tables might be prefixed with "CUSTOMER".
At the same time, the database might have tables that should be excluded from replication. For example, a set of employee tables might be prefixed with "EMPLOYEE".
Replicating Tables with a Wildcard
Using the 2-tier profile in SymmetricDS Pro, the synchronization configuration is quickly setup. To sync customer tables between nodes, a new trigger is created using the Configure->Triggers screen. The wildcard character is an asterisks that means "match any characters." So, to match the set of customer tables, the Source Table is specified as "CUSTOMER*".
From the Manage->Logging screen, or directly from the symmetric.log file, it will output the triggers that are created. The new triggers can also be verified from the Manage->Installed Triggers screen. Data capture triggers are created for CUSTOMER and CUSTOMER_ADDRESS tables, while ignoring the employee tables.
Dynamic Replication
Now that the synchronization configuration is in place, when new tables are created that match the wildcard expression, they will be automatically included in the database replication. For example, a new customer table is created.
Using the Manage->Installed Triggers screen, the "Sync Triggers" button will cause the new data capture triggers to be created immediately.
The Sync Triggers process is scheduled as a job that runs every night, but the schedule can be changed to run at any frequency using a cron expression. The expression has fields for the second, minute, hour, day of month, month, and day of week that are separated by a space. The fields are numeric, although month and day of week can also be specified by their name. For example, a cron expression of "0 0/5 9-17 * * MON-FRI" would run the job every 5 minutes between 9 AM and 5 PM on Monday through Friday.
Java Management Extensions (JMX) are available to programmatically execute the Sync Triggers process from external clients. An application could alter the database or add new tables, then call Sync Triggers over JMX to detect the changes and setup replication. SymmetricDS also includes a web frontend to access JMX operations using the MX4J HTTP Adapter. The Sync Triggers operation is found in the management bean named "org.jumpmind.symmetric.server:name=Node" under the "org.jumpmind.symmetric.server" domain.
Conclusion
When configuring synchronization, consider using a wildcard character to match the set of tables. If all tables in the catalog or schema are required to be replicated, a single Trigger entry with a wildcard is a quick and easy configuration. Adding a configuration for a specific table can be used to override any wildcard Trigger entries. SymmetricDS will use the most specific Trigger configuration. Replicating new tables automatically as they are created can be used to build unique solutions that require the system to assemble itself in response to change.