Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Offline sync and event sourcing

The CRUD-based part of our application needs:

  1. Offline bidirectional "two-way" syncing
  2. Ability to modify data until ready and then "publish".
  3. Audit log

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.

like image 531
Joel Avatar asked Feb 11 '16 21:02

Joel


People also ask

What is the difference between Event Sourcing and CQRS?

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.

When should we use Event Sourcing?

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.

What is Event Sourcing in Microservices?

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.

What is Event Sourcing model?

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.


1 Answers

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.

like image 75
VoiceOfUnreason Avatar answered Oct 11 '22 22:10

VoiceOfUnreason