Skip to content

Spring Boot

DSM ships a supported Spring Boot path centered on DsmRuntime.

Add The Starter

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

Provide Codec And Factory Beans

  • Register collections need DsmEntityCodec<E> beans.
  • Lease collections also need an entity factory bean.
  • CRDT collections need an update codec, state codec, initial state bean, and merger bean.

Configure application.yml

dsm.cluster-id and dsm.service-id are both required.

yaml
dsm:
  cluster-id: runtime-example
  service-id: runtime-example
  cluster:
    mode: standalone
  collections:
    - bean-name: routeHintsCollection
      tenant-id: shared
      application-id: gateway
      collection-id: route-hints
      schema-id: route-hints/v1
      type: REGISTER
      codec-bean: routeHintCodec
    - bean-name: shardOwnerCollection
      tenant-id: shared
      application-id: worker
      collection-id: shard-owner
      schema-id: shard-owner/v1
      type: LEASE
      codec-bean: shardOwnerCodec
      lease:
        entity-factory-bean: shardOwnerEntityFactory

Cluster Modes

ModePropertyBest fit
Standalonedsm.cluster.mode=standalonelocal development and demos
Multicastdsm.cluster.mode=multicasttrusted LAN or VPC networks
Unicastdsm.cluster.mode=unicastKubernetes and cloud deployments

Unicast settings live under dsm.cluster.unicast.*.

Security

yaml
dsm:
  security:
    enabled: true
    cluster-secret: ${DSM_CLUSTER_SECRET}
    nonce:
      window-size: 1024
      max-clock-drift: 5s

What The Starter Creates

When you use the starter, Spring auto-configures:

  • NodeInfo
  • ClusterMembership
  • DsmRuntime
  • DsmCollectionRegistry
  • DsmRuntimeLifecycle
  • DsmRuntimeRegistrationReporter
  • DsmMetrics

Collection handles are also exposed as beans using either bean-name or the default dsmCollection:<tenant>/<application>/<collection> naming scheme.