Skip to main content
Javers is a popular Java library for auditing and tracking changes to domain objects. FlowWarden Javers connects Javers audit snapshots to FlowWarden’s Change Stream engine, letting you react to audit events in real time with deserialized domain objects and full Javers metadata.

How it works

When you use @JaversSpringDataAuditable on a Spring Data repository, Javers inserts a snapshot document into the jv_snapshots collection every time an entity is saved or deleted. FlowWarden Javers watches this collection via MongoDB Change Streams and delivers events to your handler:

Setup

1. Add dependencies

2. Audit your repository

3. Create a Javers stream handler


Javers snapshot types

Javers defines three snapshot types that map to FlowWarden handler annotations:

Handler signatures

Each handler annotation supports three signature styles:

JaversChangeContext

The JaversChangeContext<T> gives you access to both Javers audit data and FlowWarden event metadata:

Javers data

FlowWarden data


FlowWarden annotations

The FlowWarden policy annotations work on @JaversStream classes, exactly as on a @ChangeStream class:
@Filter and @Pipeline are not supported on @JaversStream classes. The stream watches the whole snapshot collection and filters by entity type internally, before dispatching to your handlers; filter further inside the handler, using JaversChangeContext (changed properties, commit author, …).

Snapshot collection configuration

The Javers snapshot collection name is resolved in order:
  1. Explicit: @JaversStream(snapshotCollection = "custom_snapshots")
  2. Javers property: javers.snapshotCollectionName from application.yml
  3. Default: jv_snapshots
If you changed the Javers collection name via properties and don’t set snapshotCollection explicitly on @JaversStream, FlowWarden will auto-detect it from the Javers configuration. Make sure the property is set before the application context initializes.

Entity deserialization

FlowWarden deserializes the Javers state field into your domain object using Spring Data MongoDB’s MongoConverter. This means:
  • Standard Spring Data annotations (@Field, @Id, etc.) are respected
  • Custom converters registered with Spring are used
  • For @OnTerminal events, the entity represents the last known state before deletion

Source on GitHub

Browse the flowwarden-javers source, issues, and releases.