In SymmetricDS file synchronization, Set the target base dir path dynamically by fetching from the database bean shell script

StackOverflow https://stackoverflow.com//questions/22067456

Question

I'm using SymmetricDS for doing file synchronization between client and server node, I want to fetch the file sync target path from my database or file which is different for each client node.

I researched about it and find out that we can use shell script to change parameters like targetBaseDir , targetFileName, targetRelativeDir etc. inside before_copy_script or after_copy_script Please see http://www.symmetricds.org/doc/3.5/html/configuration.html#filesync-beanshell

Here I have the targetRelativeDir path of each node in one of my database tables, and I have to fetch it and set it to the parameter targetRelativeDir using beanshell

Please give me any direction to accomplish this.

Was it helpful?

Solution

Your BSH will look similar to the following.

String nodeId = engine.getNodeService().findIdentityNodeId();
targetRelativeDir  = engine.getSqlTemplate().queryForString(
    "select targetRelativeDir from myTable where target_node=?", new Object[] {nodeId});

I assume this will work but I have not tested it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top