Skip to main content

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:
  1. Discover all @ChangeStream beans from the Spring application context
  2. Validate the configuration — execution mode, MongoDB template availability, handler signatures
  3. Register discovered streams in the internal registry
  4. Start streams with autoStart = true after the Spring context is ready

Minimal Setup

Your @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

@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 to IMPERATIVE when not explicitly configured. For Spring WebFlux applications, set it to REACTIVE in application.yml:
If flowwarden.default-mode is not set, FlowWarden defaults to IMPERATIVE and logs:
Spring MVC applications can omit this property entirely. Spring WebFlux applications must set it to 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:
The FlowWardenConfigurationValidator runs after all singleton beans are created (SmartInitializingSingleton) and checks:
  1. Mode is resolvedflowwarden.default-mode defaults to IMPERATIVE if not set
  2. Template availableIMPERATIVE requires MongoTemplate, REACTIVE requires ReactiveMongoTemplate
All errors follow the Spring Boot error format with a Description and an Action section suggesting how to fix the issue.

Disabling FlowWarden

Set enabled = false to disable all stream processing without removing the annotation:
This is useful for running the application in a degraded mode (e.g., maintenance) or for profiles where streams should not start.

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