Skip to main content
This page is the focused reference for all supported handler method signatures. For dispatch semantics, multi-annotation combinations, and validation errors, see Event Handlers.

Parameter Styles

Typed handlers (@OnInsert, @OnUpdate, @OnDelete, @OnReplace) support three parameter styles. @OnChange supports only CONTEXT_ONLY.
DOCUMENT_ONLY and DOCUMENT_AND_CONTEXT signatures fail at startup with BeanCreationException if @ChangeStream.documentType is Document.class (the default). Set a concrete class:

Return Types — Mode Exclusivity

The return type is bound to the configured execution mode (flowwarden.default-mode):
Mixing return types across handlers in the same application is not allowed. All handler methods must consistently return void or Mono<Void> matching the configured mode. A mismatch triggers a BeanCreationException.
Other return types — CompletableFuture, Flux, String, etc. — are rejected at startup with unsupported return type.

Full Signature Matrix

For @OnChange: only void handle(ChangeStreamContext<T> ctx) is allowed.

Examples

CONTEXT_ONLY

DOCUMENT_ONLY

DOCUMENT_AND_CONTEXT

Reactive variants

Injecting Other Beans

Need a MongoTemplate, a custom service, or any other Spring bean? Inject it through the handler class (constructor or @Autowired field), not via the handler method signature:
The handler class is a regular Spring @Component (via @ChangeStream’s meta-annotation), so all standard Spring injection patterns apply.

DELETE handler caveat

For DELETE 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:
Prefer 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.