threadmill-store-memory
In-memory implementation of the JobStore SPI. Used for tests and local
development. Never for production — data is lost on restart.
When to use
Section titled “When to use”- Tests. Every contract test in
AbstractJobStoreContractTestruns against this store viaInMemoryJobStoreContractTest. The same contract tests run against Postgres and Redis, so passing on memory means the behaviour matches the real backends. - Local dev. The Spring Boot auto-config falls back to this when no
Redis is configured and no
DataSourceis present, with a loud warning. - Quickstart.
threadmill-example/GettingStartedMain.javauses this store to demonstrate the lifecycle end-to-end in one file.
What it provides
Section titled “What it provides”The same operational guarantees as the real backends:
- Atomic claim across virtual-thread workers (single mutex).
- Optimistic-lock version semantics identical to Postgres / Redis.
- All concurrency-group semantics (
EXCLUSIVE/SHARED, workflow inheritance). - Producer-side deduplication (
enqueueIfAbsent). - Maintenance lease, mutex SPI, atomic replacement, retention.
What it doesn’t provide:
- Durability across JVM restart. Everything is in process memory.
- Cross-JVM coordination. A single-process store; if you run multiple
ProcessingNodes in the same JVM they share state through this store, but separate JVMs each have their own.
Design — not a simplified fake
Section titled “Design — not a simplified fake”The in-memory store keeps the serialized wire form, not the Job object.
Every insert and saveAtomic round-trips through JsonJobSerializer, so
the serializer is exercised on every operation. This catches serializer
regressions in tests that would otherwise only surface against the real
backends.
This is deliberate. A “simpler” in-memory store that holds Job references
would diverge from the real backends in subtle ways (4-byte Unicode handling,
oversize behaviour, snapshot-on-serialize correctness) and let bugs through
the contract suite.
./gradlew :threadmill-store-memory:test