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
Provide either:
DsmEntityCodec<E>referenced bycodec-beanentity-typefor Java record entities so the starter can deriveRecordCodec
Lease Collections
Required beans:
DsmEntityCodec<E>referenced bycodec-bean, orentity-typefor record-codec derivationFunction<String, E>referenced bylease.entity-factory-bean
Lease mode can be AUTONOMOUS or QUORUM. QUORUM mode uses lease.quorum-stability-rounds to wait for stable membership before local acquire, renew, and transfer attempts are allowed.
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
entity-type: com.example.RouteHintMixed 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
suspicion-enabled: true
suspicion-quorum: 3
seed-nodes:
- 10.0.0.11:4447
- 10.0.0.12:4447
sync:
anti-entropy:
sweep-enabled: true
sweep-interval: 30s
max-concurrent-repairs: 2
security:
enabled: true
cluster-secret: ${DSM_CLUSTER_SECRET}
nonce:
window-size: 1024
max-clock-drift: 5s
max-tracked-senders: 1600
rate-limit:
max-consecutive-failures: 10
ban-duration: 30s
encryption:
enabled: true
algorithm: ChaCha20-Poly1305
collections:
- bean-name: routeHintsCollection
tenant-id: shared
application-id: gateway
collection-id: route-hints
schema-id: route-hints/v1
type: REGISTER
consistency-tier: REGISTER
entity-type: com.example.RouteHint
- 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
quorum-stability-rounds: 3
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- every collection must provide either
codec-beanor derivableentity-type - 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 - QUORUM lease
quorum-stability-roundsmust be at least1 dsm.security.nonce.max-tracked-sendersmust be within the Spring-validated range- 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.suspicion-enableddefault:truedsm.cluster.unicast.suspicion-quorumdefault:3dsm.cluster.unicast.suspicion-timeoutdefault: deriveddsm.cluster.unicast.seed-nodesdefault: empty listdsm.cluster.unicast.dns.hostnameoptionaldsm.cluster.unicast.dns.portdefault:9090
Production Runtime Knobs
| Area | Key properties |
|---|---|
| anti-entropy repair | dsm.sync.anti-entropy.sweep-enabled, sweep-interval, max-concurrent-repairs |
| trace context | dsm.observability.trace-context.enabled |
| sender replay bounds | dsm.security.nonce.window-size, max-clock-drift, max-tracked-senders |
| sender ban | dsm.security.rate-limit.max-consecutive-failures, ban-duration |
| payload encryption | dsm.security.encryption.enabled, algorithm, key-derivation-salt |
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.
CollectionLifecycleListener beans and CollectionInterceptor<?> beans are also auto-discovered and applied to the runtime. Use lifecycle listeners for registration/freeze/unregister observation, and interceptors for audit or operation metrics around collection calls.
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.