The CRUD-based part of our application needs:
Event Sourcing (or the "command pattern") is what I'm looking at to accomplish these items. I feel comfortable with solving 2&3 with this, but not clear for item one, syncing.
If timestamps are used for each command (if needed), do the offline commands need to be applied to master system as they would have been in real-time (coalesced), or can I just consider them applied as happening at the end of any command (with a more recent timestamp)?
Any basic algorithm description for command-based sync would be helpful.
CQRS is implemented by a separation of responsibilities between commands and queries, and event sourcing is implemented by using the sequence of events to track changes in data.
Indeed, Event Sourcing shines the most when we can work with the business to find the business events. Event Storming and Event Modeling proved that events work great as a way to describe business processes. We can use them as “checkpoints” of our workflow. Events are also essential as a data model.
Event sourcing is an architectural approach for (typically but not necessarily always) synchronously receiving and subsequently asynchronously distributing data (events) within an architecture. Events, once received, are persisted in a data store unique to the receiving service.
Solution. The Event Sourcing pattern defines an approach to handling operations on data that's driven by a sequence of events, each of which is recorded in an append-only store.
You'll want to review what Greg Young has to say about CQRS and Occasionally Connected Systems
Commands need to run on the system of record at the time they are received. So your offline client can work with its locally cached, stale, copy of the record, and queue up commands. When connected again, the client updates it's copy of the system of record, reconciles its queued commands with the new state of the world, and then sends the new commands to the system of record.
Greg's talk sketches how the command reconciliation worked (basically, by looking at the events the provisional commands generate, and looking for conflicts with the events recorded by the system of record). The talk strongly implies that domain experts will want event conflicts to be resolved in specific ways.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With