Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Domain events and versioning without CQRS

Hi I have the following senario which I dont understand how to get eventual consistency with:

  1. User 1 uses Task based ui to change customer name
  2. App Service calls operation on the aggregate
  3. Aggregate fires event on customername changed
  4. bus sends message using nservicebus
  5. NServicebus service dies
  6. User 2 gets aggregate and calls change address
  7. Aggregate operation called
  8. Domain event fired
  9. Message put on bus
  10. Bus restarts
  11. Message 2 picked up first
  12. Message 2 processed and other Bounded context updated with new address
  13. Message 1 picked up now which is wrong order
  14. What happens now

In 13 would there be an optimistic concurrency error if we pass the version of the aggregate in the event?

If so Message 1 new gets applied to object in the other context. How do we even maintain consistency?

This is the issue that is preventing me applying events in my domain. All help welcome.

The essential idea is to update another aggregate in another context. I am just stuck on the concurrency technicalities of this.

We are not using event sourcing or CQRS in the sense of commandhandler and commands push on the bus. It is only the event processing we want to happen asynchronously as we have an existing design which we do not wish to change.

Blair

like image 416
Blair Davidson Avatar asked Oct 21 '22 16:10

Blair Davidson


1 Answers

Generally you would be queuing the messages. If they are going into a queue you will get proper ordering. If you want to use something that does not support ordering with your servicebus then add a sequence number to your events so the other side can properly reorder them. TCP has been doing this since 1981 http://www.ietf.org/rfc/rfc793.txt :)

like image 157
Greg Young Avatar answered Oct 27 '22 10:10

Greg Young