Overview
@EnableFlowWarden activates the FlowWarden framework. Place it on a @Configuration or
@SpringBootApplication class.
It is a marker annotation — it does not perform package scanning itself. @ChangeStream
classes are discovered through Spring’s standard @ComponentScan (since @ChangeStream is
meta-annotated with @Component), and ChangeStreamBeanPostProcessor inspects all beans in
the context to find those annotated with @ChangeStream.
At startup, FlowWarden will:
- Discover all
@ChangeStreambeans from the Spring application context - Validate the configuration — execution mode, MongoDB template availability, handler signatures
- Register discovered streams in the internal registry
- Start streams with
autoStart = trueafter the Spring context is ready
Minimal Setup
@ChangeStream classes just need to be picked up by Spring’s @ComponentScan — which
happens automatically when they are in the same package (or a sub-package) as your
@SpringBootApplication class.
Attributes
| Attribute | Type | Default | Description |
|---|---|---|---|
propertyPrefix | String | "flowwarden.stream" | Prefix for FlowWarden configuration properties |
enabled | boolean | true | Globally enable or disable all streams |
@EnableFlowWarden does not have basePackages or basePackageClasses attributes.
Handler discovery relies on Spring’s standard @ComponentScan. If you need to restrict which
@ChangeStream classes are loaded (e.g., in tests), use Spring’s own
@ComponentScan(basePackages = ...) or @SpringBootTest(classes = ...).Configuration
The execution mode defaults toIMPERATIVE when not explicitly configured. For Spring WebFlux
applications, set it to REACTIVE in application.yml:
If Spring MVC applications can omit this property entirely. Spring WebFlux applications must
set it to
flowwarden.default-mode is not set, FlowWarden defaults to IMPERATIVE and logs:REACTIVE explicitly.How Auto-Configuration Works
FlowWarden uses Spring Boot’s auto-configuration mechanism. When@EnableFlowWarden is
present, three auto-configuration classes activate in order:
| Class | Condition | Provides |
|---|---|---|
FlowWardenAutoConfiguration | Always | ChangeStreamBeanPostProcessor, FlowWardenConfigurationValidator |
ImperativeFlowWardenAutoConfiguration | flowwarden.default-mode=IMPERATIVE (or missing) | ImperativeStreamManager, CheckpointStore → MongoCheckpointStore |
ReactiveFlowWardenAutoConfiguration | flowwarden.default-mode=REACTIVE | ReactiveStreamManager, CheckpointStore → ReactiveMongoCheckpointStore |
Startup validation details
Startup validation details
The
FlowWardenConfigurationValidator runs after all singleton beans are created
(SmartInitializingSingleton) and checks:- Mode is resolved —
flowwarden.default-modedefaults toIMPERATIVEif not set - Template available —
IMPERATIVErequiresMongoTemplate,REACTIVErequiresReactiveMongoTemplate
Description and an Action section
suggesting how to fix the issue.Disabling FlowWarden
Setenabled = false to disable all stream processing without removing the annotation:
Full Example
application.yml
See Also
Quickstart
Full getting-started guide with dependency setup
@ChangeStream
Declare a Change Stream handler class
Imperative vs Reactive
Choose the right execution mode
Configuration
All FlowWarden configuration properties

