Search code examples
symmetricds

MCV example of SymmetricDS 3.8 embedded?


SymmetricDS helpfully provides a snippet of code to run a basic node from Java. No context is provided, however, and there is no compilable example in their github repository.

This other user's example gets a little closer, but still fails for me at getcEngine().openRegistration(...) with exception:

java.lang.IllegalStateException: This node has not been configured.Could not find a row in the identity table

Have you successfully run an embedded client with version 3.8? Can you provide a minimal example that gets past the setup stage?


Solution

  • The linked examples actually do work, but an embedded client does not have its node database set up for you. At a minimum, you need a sym_node and sym_node_identity row for this client. The SQL below works for me.

    Also, here's a minimum compilable example for IntelliJ Idea with a scripted demo of symmetricDS 3.8.16.

    CREATE TABLE "sym_node"(
        "node_id" VARCHAR NOT NULL PRIMARY KEY ,
        "node_group_id" VARCHAR NOT NULL,
        "external_id" VARCHAR NOT NULL,
        "sync_enabled" INTEGER DEFAULT 0,
        "sync_url" VARCHAR,
        "schema_version" VARCHAR,
        "symmetric_version" VARCHAR,
        "database_type" VARCHAR,
        "database_version" VARCHAR,
        "heartbeat_time" TIMESTAMP,
        "timezone_offset" VARCHAR,
        "batch_to_send_count" INTEGER DEFAULT 0,
        "batch_in_error_count" INTEGER DEFAULT 0,
        "created_at_node_id" VARCHAR,
        "deployment_type" VARCHAR
    );
    
    CREATE TABLE "sym_node_identity"(
        "node_id" VARCHAR NOT NULL PRIMARY KEY ,
        FOREIGN KEY ("node_id") REFERENCES "sym_node" ("node_id")
    );
    
    insert into sym_node (node_id,node_group_id,external_id,sync_enabled,sync_url,schema_version,symmetric_version,database_type,database_version,heartbeat_time,timezone_offset,batch_to_send_count,batch_in_error_count,created_at_node_id) 
     values ('003','store','003',1,null,null,null,null,null,current_timestamp,null,0,0,'000');
    
    INSERT INTO "sym_node_identity" VALUES('003');