So with cqrs, we accept that consistency is eventual.

However, that doesn't mean that the user has to continually poll, or that eventual means an update has to take more then 500ms to sync.

For the sake of UX, we want to at least give the illusion of consistency, or if not possible, be as transparent as possible.

With that in mind, I have this setup:

  • angularjs web client, consumes
  • webapi restful services, sends commands to
  • nservicebus command handlers, saves to
  • neventstore, dispatches events to
  • nservicebus event handlers, sends message to
  • signalr hub, sends notifications to
  • angularjs web client

so with that setup, theoretically

  • some initiates a request
  • the server validates the request
  • sends out the necessary commands

In the mean time

  • the client gets a 200 response
  • updates the view: working on it
  • gets message sometime later: done, here's the updated data

Here's where things get interesting, each command could spawn multiple events. Not sure if this is a serious no, no, or not, but that's how it is currently. For example, a new customer spawns CustomerIDCreated, CustomerNameUpdated, CustomerAddressUpdated, etc...

Which event handler needs to notify the client? Should all of them in a progress bar style update?


Broadly speaking, an event handler should notify the client if the client is (or might be) interested in the information.

However, the granularity of the message is important.

Remember that whenever you end up passing information over the network you move from the realm of sub-microsecond processing to multi-milliseconds of elapsed time.

For this reason, I'm not convinced the fine granularity of events that you described is appropriate.

Jim Webber has a fair bit to say on the subject, recommending that the granularity should be similar to what you'd use if the service was an actual person in a mid to large size business. In your case, a single CustomerUpdated message instead of multiple smaller messages.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.