@Checkpoint, FlowWarden saves a resume token to MongoDB after each processed event, and reloads it on startup to continue exactly where it left off.
Quick setup
Add@Checkpoint to any @ChangeStream class:
How it works
Saving strategies
Two independent mechanisms control when the resume token is persisted. They can be used together.Every N events — saveEveryN
Saves the token after every N successfully processed events. The counter increments only on success — failed events do not advance it.
Periodic timer — saveIntervalSeconds
Saves the latest received token on a fixed schedule, regardless of event volume. This acts as a heartbeat — the token advances even on low-traffic streams where saveEveryN would take a long time to trigger.
The periodic timer saves the token of the last event received, even if it was not yet checkpointed by
saveEveryN. This means the two mechanisms are complementary: saveEveryN tracks processed events precisely, the timer provides a safety net for idle periods.Combining both
Both mechanisms are active by default. The token is saved whichever fires first:Start position
startPosition controls where the stream starts consuming when it boots.
| Value | Behaviour |
|---|---|
RESUME (default) | Load the checkpoint from _fw_checkpoints. If none exists (first start), begin from the latest event. |
LATEST | Ignore any existing checkpoint and start from the latest event. Previous events are never replayed. |
Attribute reference
| Attribute | Type | Default | Description |
|---|---|---|---|
strategy | CheckpointStrategy | MONGODB | Storage backend. Currently only MONGODB is supported. |
saveEveryN | int | 1 | Save after every N successfully processed events. Must be > 0. |
saveIntervalSeconds | int | 5 | Periodic save interval in seconds. Set to 0 to disable. Must be ≥ 0. |
startPosition | StartPosition | RESUME | RESUME to reload last checkpoint; LATEST to ignore it. |
onHistoryLost | OnHistoryLost | FAIL | Strategy when the saved resume token has expired from the oplog. See @Checkpoint reference. |
Internal storage
Checkpoints are stored in the_fw_checkpoints collection of your MongoDB database. The collection is created automatically on first use.
Each document is keyed by stream name and contains the resume token and metadata:
Common patterns
Exactly-once semantics
Exactly-once semantics
FlowWarden provides at-least-once delivery by default. A crash between processing and checkpointing causes the last few events to be reprocessed on restart.To achieve exactly-once, use Spring’s See the Transactions guide for full setup instructions, constraints, and best practices.
@Transactional combined with ctx.saveCheckpointNow() to commit your business writes and the checkpoint atomically:Disabling checkpoint for dev/test
Disabling checkpoint for dev/test
Omit
@Checkpoint entirely — no tokens are persisted and the stream always starts from the latest event:Multiple streams, independent checkpoints
Multiple streams, independent checkpoints
Each stream has its own checkpoint entry in
_fw_checkpoints, keyed by stream name. Two streams on the same collection checkpoint independently:See Also
@Checkpoint reference
Full annotation reference
How it Works
Where checkpointing fits in the event processing pipeline
Filtering Events
How filtered events interact with resume tokens

