如何在嵌入式模式下使用 symmetricDS

How to use symmetricDS in Embedded mode

我有以下用例: 位于不同机器上的数据库 A(主)和数据库 B(从)。 我想将数据库 A 与数据库 B 同步。 我想使用嵌入的 SymmetricDS 创建一个 java 应用程序。 由于没有关于如何执行此操作的文档,我想要一个示例或文档。 请帮助我,我卡住了。

文档中有一节关于将 symmetricDs 引擎嵌入 Java SE 应用程序:http://www.symmetricds.org/doc/3.6/user-guide/html-single/user-guide.html#deployment-options-embedded

这是一个如何 运行 嵌入式模式下的对称引擎服务器的示例,它对我来说非常有效:

public class ClientNode {
 private ClientSymmetricEngine cEngine;
 private File propFile;


 public ClientNode(File file) throws FileNotFoundException, IOException {
  propFile = file;
  Properties propertiesFile = new Properties();
  propertiesFile.load(new FileReader(propFile));
  cEngine = new ClientSymmetricEngine(propertiesFile, true);
  getcEngine().openRegistration("client", "001");// client is the name of the node group and 001 is the ID
  getcEngine().setup();
  getcEngine().start();
 }

 public ClientSymmetricEngine getcEngine() {
  return cEngine;
 }

 public void setcEngine(ClientSymmetricEngine cEngine) {
  this.cEngine = cEngine;
 }
}

主要 class :

public static void main(String[] args) {
 
    
 try {
  new ClientNode(new File("client.properties"));
  SymmetricWebServer node = new SymmetricWebServer("master.properties");
  node.setWebAppDir("Web"); 
  node.setJoin(false);
  node.start();
  // this will stop the node
  //node.stop();
  }catch (Exception e) {
   e.printStackTrace();
  }
    
 }

属性文件:

client.properties :

external.id=001
engine.name=client-001
sync.url=http\://localhost\:31415/sync/client-001
group.id=client
db.url=jdbc\:mysql\://localhost/easyexchangedb_slave
db.driver=com.mysql.jdbc.Driver
db.user=root
registration.url=http\://localhost\:31415/sync/server
db.password=

master.properties :

external.id=server
engine.name=server
sync.url=http\://localhost\:31415/sync/server
group.id=server
db.url=jdbc\:mysql\://localhost/easyexchangedb_master
db.driver=com.mysql.jdbc.Driver
db.user=root
registration.url=http\://localhost\:31415/sync/server
db.password=
auto.registration=true