Prerequisites
Java 17+
Spring Boot 3.x requires Java 17 as a minimum.
Spring Boot 3.x
Spring MVC or Spring WebFlux — both are supported.
MongoDB Replica Set
Change Streams require a Replica Set. A single-node RS is fine for local dev.
Step 1 — Add the dependency
spring-boot-starter-data-mongodb.
Using the BOM (optional)
If you also pullflowwarden-stream-core-testkit (for backend implementors) or future satellite modules, import the flowwarden-bom in your dependencyManagement to keep versions aligned:
Maven
Step 2 — Configure your application
Add the following to yourapplication.yml:
- Spring MVC (imperative)
- Spring WebFlux (reactive)
flowwarden.default-mode is optional — it defaults to IMPERATIVE when omitted. Only set it explicitly if you need the reactive mode.Step 3 — Enable FlowWarden
Add@EnableFlowWarden to your main application class:
@ChangeStream classes are discovered through Spring’s standard component scanning — @ChangeStream is meta-annotated with @Component, so no extra @ComponentScan configuration is needed.
Step 4 — Create your first handler
Declare a Spring bean annotated with@ChangeStream and add a handler method:
Order is a Spring Data @Document class:
Step 5 — Run it
Start your application. On boot, you will see a log line for each discovered stream:orders collection — your handler fires immediately.
MongoDB shell
What’s next?
How it Works
Understand the startup lifecycle and the event processing pipeline
Typed handlers
Use @OnInsert, @OnUpdate, @OnDelete for operation-specific logic
Checkpoint & Resume
Survive restarts without missing or replaying events
Filtering Events
Push aggregation pipelines to MongoDB or filter in Java