Skip to content

Getting Started

This path gives you the smallest DSM runtime you can run from Java code.

Prerequisites

  • Java 25+
  • Maven 3.6+
  • A service process that can host the runtime

Add The Dependency

xml
<dependency>
  <groupId>com.leanowtech.dsm</groupId>
  <artifactId>dsm-core</artifactId>
  <version>${dsm.version}</version>
</dependency>

Build A Runtime

java
NodeInfo self = new NodeInfo("node-a", "127.0.0.1", 9090);

DsmRuntime runtime = DsmRuntimeBuilder.builder()
    .clusterId("runtime-example")
    .serviceId("gateway-service")
    .membership(new StandaloneClusterMembership(self))
    .build();

runtime.register(CollectionSpecBuilder.<RouteHint>register(
        "shared",
        "gateway",
        "route-hints")
    .schemaId("route-hints/v1")
    .codec(new RouteHintCodec())
    .build());

runtime.start();

Model An Entity

Register and CRDT updates implement DsmEntity<E>. Lease collections implement LeaseEntity<E>. Entities are immutable value objects, typically records.

java
public record RouteHint(String entryKey, EntityMetadata metadata, String address)
        implements DsmEntity<RouteHint> {
    @Override
    public RouteHint withMetadata(EntityMetadata metadata) {
        return new RouteHint(entryKey, metadata, address);
    }
}

What To Try First

  1. Start with a register collection for route hints or simple metadata.
  2. Add a lease collection when you need ownership or fencing.
  3. Add a CRDT collection when every node needs local writes plus convergent repair.

Run The Example

The repository includes a ready-made runtime example:

bash
mvn -pl dsm-examples exec:java

That example creates one register, one lease collection, and one CRDT collection using the same builders shown above.

Next Steps