I am building a web app that users can edit and share notes. Users should be connected to notes with roles (owner, read, read-write). This is an occasionally connected system so I chose to do the syncing using CQRS and event sourcing. Following Greg Young's presentation [36:20 - 38:40], the flow would be as follows:

  1. Client does changes while offline.
  2. Client connects to the Internet.
  3. The "store and forward" sends the events that occurred while the client was offline.
  4. Client compares the local events with the received events and does a merge, deciding what commands to keep. Then updates local view model.
  5. Client sends the stored commands (created offline) to the server.
  6. Server executes the commands and generates events that are stored in event store.
  7. "store and forward" holds the events each user is interested in, until the users come back online.

The question is: How does the "store and foreword" decide what events should be sent to each user?

Obviously sending all events would compromise the security of other users.

1

There are 1 answers

0
Roman Eremin On

Since your client knows which aggregates it displays, then it can just tell backend "hey, are there events for aggregateIds [...] since [timestamp]?".

This is how reSolve framework keeps UI reactive - client subscribes to events for particular aggregateId and receives them in real time via websockets.

So one answer to your question could be "let user ask for events (aggregateIds) he is interested in"