I have a requirement for a "smart client" app using web services to talk to servers. It's a fairly complex collaborative domain involving many other systems so having thought it through we believe a DDD/CQRS/ES style approach is suitable. I've attended Greg's excellent 3-day course but am now a little fuzzy on the details of synchronising occasionally-connected clients. I understand the fundamental concept of "merging" event streams, but have questions on where and how that happens.Currently my plan is keep the Domain logic on the server and send commands synchronously from the client via WCF to have them handled, whereupon the events would come back one way or another. However this means the application would have to be "read only" when offline for some reason (network connection, server issues etc) and of course there is a performance hit on the network round-trip. As such I'd like to overcome my fears over implementing a full disconnectable system with event merging etc.
I've today watched (twice) Greg's video "In The Brain of Greg Young: CQRS, not just for server systems" and so now I think I can formulate a couple of specific questions:
Resolving conflicting eventsSince the essence of events is that they happened and can't be denied, if a client receives events from other clients (i.e. via the "store and forward" subscription-based approach Greg mentions in his video) that conflict with events the client has already stored locally, it's not possible for the client to resolve the conflict by deleting "losing" events.
So what can we do? Users of both clients will have gone about their day assuming their commands were processed successfully (they were, after all). From the video it looks like we build some way of discovering and displaying a UI for the commands that caused the conflicts with incoming events, but we can't delete the events and try again with a different command, we surely have to expect the user to issue some sort of compensating command? Meanwhile, now we're reconnected our events are making their way out to other clients, which leads me to...
So how would the event versions be and how would the server handle the merge of the example above?
server must accept that the thing happened in the real world. It would be a downstream event processor (think SEP/CEP). It woud raise another event that there is a patient with a possible adverse reaction happening. Its not a command any more because the server *must* accept it.
It would be awesome to get a reply from Greg on this! :)