title: Showing changes in View when using CQRS & DDD with Domain Events & ServiceBus
body: <p>I'm a little confused about the flow in a system using domain events to build the read model.  Particularly, how do we deal with the fact that the user expects data (and its view) to change when they complete a command, but due to our system architecture (non-blocking calls to publish events) the actual database might not change before the page is reloaded?</p>
  
  <p>I'm hoping to move the design of one of our systems more inline with CQRS using events and a service bus.</p>
  
  <p>Let's say my flow goes as such:</p>
  
  <ol>
  <li><p>User clicks button in View to perform Task of removing Payment Method from their Account.</p></li>
  <li><p>Controller calls PaymentMethodRemovalService, passing it accountId &amp; paymentMethodId.</p></li>
  <li><p>Controller uses AccountRepository to retrieve Account and calls account.RemovePaymentMethod(id)</p></li>
  <li><p>Account validates that operation can occur and publishes event PaymentMethodRemovedMessage(accountId, paymentMethodId)</p></li>
  <li><p>Because event publishing is asynchronous, we now have to return from service and return view from the controller - <strong>but our actual data isn't updated yet</strong>!</p></li>
  <li><p>A handler, IHandle&lt; PaymentMethodRemovedMessage >, hears the event and removes the actual row from the DB</p></li>
  </ol>
  
  <p>So, what's a guy to do?</p>
  
  <p>I could simply, say, remove the div that was displaying the payment method.  This may work in an AJAX scenario, but what if I'm using Post-Redirect-Get to support non-JavaScript clients.  Then I will be firing my Get and reading the data from the Query side of things, potentially before it's updated.</p>
  
  <p>Do I just show a notification saying their request to remove the payment method has been submitted?  (which doesn't seem to friendly, makes sense for submitting an order, but not for, say, changing an address).</p>
  
  <p><strong>Is there a way to reconcile implementing changes as decoupled asynchronous events and showing the user data that reflects their current change?</strong></p>
  
  <p>EDIT:  My question is quite similar to <a href="https://stackoverflow.com/questions/3380431/cqrs-ddd-synching-reporting-database">CQRS, DDD synching reporting database</a>  I have to say, the answer given there and also alluded to here, has a bit of a smell to it - wrangling the UI to show an update that's out of band with the read DB, so to speak.  I was hoping for something a little cleaner.</p>