React to Javers audit changes in real time with deserialized domain objects and commit metadata
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.
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:
Each handler annotation supports three signature styles:
// Entity + context — full access@OnInitialvoid handle(Product product, JaversChangeContext<Product> ctx) { }// Context only — useful for @OnTerminal where entity state may be minimal@OnTerminalvoid handle(JaversChangeContext<Product> ctx) { }// Entity only — simple cases@OnUpdatevoid handle(Product product) { }
All standard FlowWarden annotations work on @JaversStream classes:
@JaversStream(entityType = Order.class)@Checkpoint(saveEveryN = 1)@RetryPolicy(maxAttempts = 3)@DeadLetterQueue(retentionDays = 30)public class OrderAuditHandler { @OnUpdate void onUpdated(Order order, JaversChangeContext<Order> ctx) { // If this throws, FlowWarden retries 3 times then sends to DLQ externalService.notifyOrderChange(order, ctx.getChangedProperties()); } @Filter boolean filter(ChangeStreamContext<?> ctx) { // Application-side filtering before dispatch return true; }}
@Pipeline also works and is applied in addition to the automatic entity type filter. Use it for extra server-side filtering (e.g., filtering by specific changedProperties or commitMetadata.author).
Javers property:javers.snapshotCollectionName from application.yml
Default:jv_snapshots
# application.yml — if you customized the Javers collection namejavers: snapshotCollectionName: my_audit_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.