Binyamin Melepat Binyamin Melepat - 3 months ago 48
Java Question

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

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

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.


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.