Parameter Styles
Typed handlers (@OnInsert, @OnUpdate, @OnDelete, @OnReplace) support three parameter styles. @OnChange supports only CONTEXT_ONLY.
Return Types — Mode Exclusivity
The return type is bound to the configured execution mode (flowwarden.default-mode):
Other return types —
CompletableFuture, Flux, String, etc. — are rejected at startup with unsupported return type.
Full Signature Matrix
- Imperative (void)
- Reactive (Mono)
For
@OnChange: only void handle(ChangeStreamContext<T> ctx) is allowed.Examples
CONTEXT_ONLY
DOCUMENT_ONLY
DOCUMENT_AND_CONTEXT
Reactive variants
Injecting Other Beans
Need aMongoTemplate, a custom service, or any other Spring bean? Inject it through the handler class (constructor or @Autowired field), not via the handler method signature:
@Component (via @ChangeStream’s meta-annotation), so all standard Spring injection patterns apply.
DELETE handler caveat
ForDELETE events, MongoDB does not provide a fullDocument. If you use DOCUMENT_ONLY or DOCUMENT_AND_CONTEXT on @OnDelete, the doc parameter will be null at runtime:
CONTEXT_ONLY for @OnDelete and use ctx.getDocumentKey() to identify the affected document:
See Also
Event Handlers
Dispatch priority, multi-annotation combinations, validation errors.
@ChangeStream
Parent class annotation —
documentType, modes, behavior flags.ChangeStreamContext
The context object passed to every handler.
@Filter
Application-side filtering and signature constraints with
@OnDelete.