Where does Event Sourcing store events?

The application manages the event store and replay. CoAkka Runtime can deliver committed events to named work, such as updating a customer directory.

Record events and rebuild a customer tier

Use the customer scenario from the CQRS guide to illustrate a new design. When a tier changes, the business handler checks eligibility and appends an event to the history of customer-42. The recorded history supplies the current tier or the tier at an earlier point.

Position Event in the event store Tier after applying the event
1 CustomerRegistered · tier = standard Standard
2 CustomerTierChanged · tier = gold Gold

How the application replays events

Read the customer’s history in order and apply each event. Stop at the first record and the tier is Standard. Apply the second and it becomes Gold. The application can rebuild the state by reading the event store directly.

Rebuild the directory after the updater stops

The directory is a read model built from the history. If it has applied through the first record, the updater reads the second event from the event store and applies the missing change.

Save the applied position with the directory update when both fit in one transaction. If the second event is delivered again, use the customer ID and event position to avoid applying the change twice. Keep replay focused on rebuilding data.

Where CoAkka Runtime delivers events

The application records the event
Tier change request → handler checks eligibility → append and commit the event in the event store
Deliver the committed event
Application reads the committed event → CoAkka Runtime delivers it to the example target projection.customer_directory → handler updates the directory

If CoAkka Runtime reports a Deadletter because the route is missing, the committed event remains in the event store. The application can fix the route and resume from the saved position. After a timeout, check that position because the directory may already have updated. Reuse the event identity on retry so the handler can recognize duplicates.

References