Skip to main content

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.
MongoDB must be running as a Replica Set — Change Streams are not available on standalone instances. For local development, start MongoDB with --replSet rs0 or use a Docker Compose setup.

Step 1 — Add the dependency

No additional dependencies needed. FlowWarden uses only Spring Data MongoDB, which is already on your classpath via spring-boot-starter-data-mongodb.

Using the BOM (optional)

If you also pull flowwarden-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 your application.yml:
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:
This activates the FlowWarden auto-configuration. @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:
Where Order is a Spring Data @Document class:
When documentType is set, FlowWarden infers the collection name from the @Document annotation (or the decapitalized class name if none). No need to repeat it in @ChangeStream(collection = "orders").

Step 5 — Run it

Start your application. On boot, you will see a log line for each discovered stream:
Then insert a document in the 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