CQRS & event sourcing
Send commands that add events to a log, and watch a read view built from those events. Move the slider to rebuild the balance as it was after any earlier event.
Step through one command
The bank account acct:42 has 3 events that add up to $100. Pick a command and when the app reads the balance, then press Next step. Back takes you to the step before.
On: the view is thrown away and built again by replaying every event.
With these settings: The withdrawal became event 4, and the account is now $70. The read at 50 ms showed $100, an old balance, because the view caught up only at 200 ms.
- Bank app — acct:42 — healthy
- Write side — checks rules — healthy — NOW — checking
- Event store — only adds — healthy
- Balance view — read side — healthy
- Projector — builds views — healthy
- Broker — events — healthy
- Command
- Read
- New event or view update
- Published event
Step 1 of 7 · Write side
Done: The app sends a command
- What happens
- The command asks to take $30 from acct:42.
- Why
- A command is a request to change something, so it can still be refused.
- What changes
- The write side starts to check it.
- Next
- The write side loads the account's events
Event log
6 more to go. Press a line to go back to that step.
Step 1 of 7: Write side. The app sends a command. The command asks to take $30 from acct:42.
What this simplifies. This run follows one account, with whole events and a stated 200 ms lag. A real projector's lag depends on the broker and the load. A real replay of millions of events takes a long time, which is one reason teams keep snapshots.
Try it yourself
The same account, acct:42, starting at $100. Send commands in any order, then move the slider to see the balance after any earlier event, or rebuild the view from every event.