Skip to content

Standalone Quickstart

This is the cleanest path for teams integrating DSM directly into a Java service without Spring Boot.

1. Add The Core Module

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

2. Create The Runtime

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

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

3. Register Collections

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

runtime.leaseRegister(LeaseCollectionSpecBuilder.<ShardOwner>lease(
        "shared",
        "worker",
        "shard-owner")
    .schemaId("shard-owner/v1")
    .codec(new ShardOwnerCodec())
    .entityFactory(ShardOwner::blank)
    .build());

4. Start The Runtime

java
runtime.start();

At that point the runtime exposes collection handles and a diagnostics surface.

5. Inspect Runtime State

java
RuntimeDiagnostics diagnostics = runtime.diagnostics();
System.out.println(diagnostics.totalEntries());
System.out.println(diagnostics.clusterView());

Repository Reference

The best reference for this flow is the runtime example factory in dsm-examples, which builds a runtime with register, lease, and CRDT collections in one place.