Hi,
I have been reading and watching the videos related to CQRS/ES in occasionally connected clients, and I have some questions
1. Greg talks about a "pending queue of commands" on the client, and the events which would have been produced if the commands were executed. Where are these events stored? I don't think they should be stored in the "normal" event store, because we must be able to remove them (along with the removal of a conflicting command for example) So I guess we should store the events in a pending queue/store of events, and change the repository to load events from the event store, and then apply the events from the pending queue/store in order to load the "current" aggregate. So the repository would be different from the server repository, because we don't have a pending queue on the server. Of course there could be some variations of this, for example embedding the events in the commands (since we already want to have some links) and storing them along with the commands in the pending commands queue.
Also, we might need to display somehow in the viewmodel whatever has been changed (like git plugins for explorer/visual studio do) - this would mean that anyway the event handlers which build the read models would have to know whether an event is commited or not for example. Would introducing a bool property like "IsPending" in all events make sense in this case? Since events are part of the domain, this would mean that the "IsPending" property is also part of the domain, does this make sense? Using this mechanism, we would have the command handlers load all events in order to build the current aggregate domain model, but having the handlers which build the read models decide whether to use the pending events or not. For example we could build a "server view", by filtering out all pending events. Does this make sense?
2. I also have some questions related to the process which executes after the merge has been done. So for example I have the list of new events from the server, I have the events generated by the pending commands, the client would for example delete a command which would conflict with some new events, and the new list of commands would be sent to the server. If the client gets a success reply (meaning that the commands were executed succesfully on the server) then it will get the events generated by the pending commands and store them in the event store. We know that we would have the same event store as the server, because we have the same domain logic and code on the client and on the server. But since this client is subscribed to this types of events to the server, the events would get to the client again if we don't filter them on the server or on the client. (I'm thinking that publishing an event to a "channel", but don't send it to a particular client subscribed to that channel sounds aliitle bit weird). So how would you do this?
3. How would you approach the next problem: I have just installed the smart client application and I start it. On the server there are already events which interest me, and I want to get them in order to build my domain model (for example some documents which I have already built using some other clients). The "persistant subscription" wouldn't help me in this case, because my client is subscribing only after the application has started the first time (or at least that's what I presume). So I need to download the events myself using other mechanism. If for example I want to download all documents which I have worked in the past, the server would have to query the read model and filter by OwnerId, and using all aggregates ids which he got from this query he will send me all the events with this aggregates id. Doesn't this have a smell already? Querying the read model since the client is only interested in events, and not read model? The read model could be stale for example. Or should we extend the Event Store to also include some information which could help us to get the events directly (like adding an OwnerId column).
Sorry for the chaotic thoughts/questions and thanks in advance.