我正在尝试嵌入对称DS http://www.symmetricds.org/3.7 在使用H2数据库的java应用程序中。该应用程序是一个客户端节点并使用该类ClientSymmetricEngine
来自 SymmetricDS API。
主节点运行独立的 symds 服务器,当我使用应用程序中先前测试中已配置的数据库时,我能够同步数据。
当在新数据库上运行应用程序时,它会抛出以下异常:
java.lang.IllegalStateException: This node has not been configured.Could not find a row in the identity table
at
org.jumpmind.symmetric.service.impl.RegistrationService.openRegistration(RegistrationService.java:562)
at
org.jumpmind.symmetric.service.impl.RegistrationService.openRegistration(RegistrationService.java:530)
at
org.jumpmind.symmetric.service.impl.RegistrationService.openRegistration(RegistrationService.java:519)
at
org.jumpmind.symmetric.AbstractSymmetricEngine.openRegistration(AbstractSymmetricEngine.java:890)
at syncdemo.ClientNode.<init>(ClientNode.java:32)
at syncdemo.SyncDemo.main(SyncDemo.java:37)
如何通过API在客户端节点创建SYM表?
我得到了同步代码here https://stackoverflow.com/questions/32291129/how-to-use-symmetricds-in-embedded-mode。 ClientNode 类中使用的如下:
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("store", "001");
getcEngine().setup();
getcEngine().start();
}
public ClientSymmetricEngine getcEngine() {
return cEngine;
}
public void setcEngine(ClientSymmetricEngine cEngine) {
this.cEngine = cEngine;
}
}
从这里调用 clientNode 类:
public class SyncDemo {
public static void main(String[] args) {
try
{
new ClientNode(new File("/client.properties"));
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
client.properties 文件的内容:
external.id=001
engine.name=store-001
sync.url=http://192.168.1.107:31415/sync/corp-000
group.id=store
db.url=jdbc:h2:./syncdata/store001;AUTO_SERVER=TRUE;LOCK_TIMEOUT=60000
db.driver=org.h2.Driver
db.user=symmetric
registration.url=http://192.168.1.107:31415/sync/corp-000
db.password=
auto.config.database=true
我刚刚注意到,即使 SYM 表存在于客户端节点的数据库中,也会引发相同的异常,除非在 SYM_NODE 和 SYM_NODE_IDENTITY 表中插入适当的数据。