Spring Boot
This guide is the supported Spring Boot integration path for DSM. Use it when you want runtime creation, collection registration, and lifecycle management driven by configuration and beans instead of manual bootstrap code.
What The Starter Does
The starter builds a DsmRuntime from dsm.* properties, validates collection definitions, registers configured collections, starts lifecycle management, and exposes collection handles as beans.
For most teams, that means:
- declare the starter dependency
- provide supporting codec and factory beans
- describe collections in
application.yml - inject typed collection handles into your service beans
Add The Starter
<dependency>
<groupId>com.leanowtech.dsm</groupId>
<artifactId>dsm-spring-boot-starter</artifactId>
<version>${dsm.version}</version>
</dependency>Required High-Level Properties
These two properties are required for every Spring Boot integration:
dsm.cluster-iddsm.service-id
They define the DSM isolation boundary and service-family identity. Keep them stable across nodes that should belong to the same logical DSM deployment.
Supporting Beans By Collection Type
Register Collections
Required bean:
DsmEntityCodec<E>referenced bycodec-bean
Lease Collections
Required beans:
DsmEntityCodec<E>referenced bycodec-beanFunction<String, E>referenced bylease.entity-factory-bean
Important runtime rule:
- Spring currently supports only
AUTONOMOUSlease mode on this path
CRDT Collections
Required beans:
DsmEntityCodec<E>referenced bycodec-beanMergeableStateCodec<S>referenced bycrdt.state-codec-bean- initial state bean referenced by
crdt.initial-state-bean StateMerger<E, S>referenced bycrdt.merger-bean
Minimal Configuration Example
dsm:
cluster-id: runtime-example
service-id: gateway-service
cluster:
mode: STANDALONE
collections:
- bean-name: routeHintsCollection
tenant-id: shared
application-id: gateway
collection-id: route-hints
schema-id: route-hints/v1
type: REGISTER
consistency-tier: REGISTER
codec-bean: routeHintCodecMixed Register, Lease, And CRDT Example
dsm:
cluster-id: runtime-example
service-id: gateway-service
runtime:
dynamic-registration: false
cluster:
mode: UNICAST
unicast:
gossip-port: 4447
gossip-interval: 1s
gossip-fanout: 3
failure-threshold: 5
seed-nodes:
- 10.0.0.11:4447
- 10.0.0.12:4447
security:
enabled: true
cluster-secret: ${DSM_CLUSTER_SECRET}
nonce:
window-size: 1024
max-clock-drift: 5s
collections:
- bean-name: routeHintsCollection
tenant-id: shared
application-id: gateway
collection-id: route-hints
schema-id: route-hints/v1
type: REGISTER
consistency-tier: REGISTER
codec-bean: routeHintCodec
- bean-name: shardOwnersCollection
tenant-id: shared
application-id: worker
collection-id: shard-owner
schema-id: shard-owner/v1
type: LEASE
consistency-tier: LEASE
codec-bean: shardOwnerCodec
lease:
mode: AUTONOMOUS
term: 10s
renew-skew: 3s
expiry-grace: 500ms
entity-factory-bean: shardOwnerEntityFactory
- bean-name: requestCounterCollection
tenant-id: shared
application-id: billing
collection-id: request-counter
schema-id: request-counter/v1
type: CRDT
consistency-tier: CRDT
codec-bean: requestCounterCodec
crdt:
state-codec-bean: requestCounterStateCodec
initial-state-bean: requestCounterInitialState
merger-bean: requestCounterMergerProperty Validation Rules That Matter
The Spring integration validates collection definitions before runtime assembly. The most important rules are:
- every collection must set
tenant-id,application-id,collection-id,schema-id, andcodec-bean - every collection locator must be unique
bean-name, when present, must be unique- register collections must declare
consistency-tier: REGISTER - lease collections must declare
consistency-tier: LEASE - CRDT collections must declare
consistency-tier: CRDT - lease
renew-skewmust be smaller thanterm - referenced supporting beans must exist
Cluster Modes
| Mode | Property | Best fit |
|---|---|---|
| Standalone | dsm.cluster.mode=STANDALONE | local development, demos, single-node experiments |
| Multicast | dsm.cluster.mode=MULTICAST | trusted LAN or VPC environments where multicast is available |
| Unicast | dsm.cluster.mode=UNICAST | Kubernetes and cloud deployments |
Node Properties
dsm.node.iddefault: random UUIDdsm.node.hostdefault: resolved local host addressdsm.node.portdefault:9090
Multicast Properties
dsm.cluster.multicast.groupdefault:239.0.77.1dsm.cluster.multicast.portdefault:4446dsm.cluster.multicast.heartbeat-intervaldefault:1sdsm.cluster.multicast.failure-thresholddefault:5
Unicast Properties
dsm.cluster.unicast.gossip-portdefault:4447dsm.cluster.unicast.gossip-intervaldefault:1sdsm.cluster.unicast.gossip-fanoutdefault:3dsm.cluster.unicast.failure-thresholddefault:5dsm.cluster.unicast.seed-nodesdefault: empty listdsm.cluster.unicast.dns.hostnameoptionaldsm.cluster.unicast.dns.portdefault:9090
Collection Bean Naming And Injection
Each configured collection handle is exposed as a Spring bean.
Naming rules:
- if
bean-nameis set, it becomes an alias you can inject by name or qualifier - a stable bean name is always registered as
dsmCollection:<tenant>/<application>/<collection>
Example injection by explicit alias:
@Service
public class RouteHintService {
private final DsmRegister<RouteHint> routeHints;
public RouteHintService(@Qualifier("routeHintsCollection") DsmRegister<RouteHint> routeHints) {
this.routeHints = routeHints;
}
}Runtime Customization Hooks
If you need to customize the builder before the runtime is built, provide a DsmRuntimeBuilderCustomizer bean.
This is the right place for advanced setup such as a custom collection store, custom registry, or clock override.
What Gets Auto-Configured
The Spring path creates or exposes these core beans:
NodeInfoClusterMembershipDsmRuntimeDsmCollectionRegistryDsmRuntimeLifecycleDsmRuntimeRegistrationReporterDsmMetrics
When To Use The Reference Pages
Use the Spring guide for the integration sequence. Use the reference pages when you need exact field-level detail.