vendredi 20 mai 2016

Loading data to validate a business rule with CQRS and Event Sourcing

I have a command called CreateItem which has a name of the item (an aggregate root) to be created. Now I have a business rule that says all items must be uniquely named. If I'm using event sourcing there is no way to look this up from the write model, so I need to have something which I think is called a projection which will be a table which contains the names of every "Item" which will be kept up to date based on the ItemCreated event. Now is it ok for the code that handles the CreateItem command to check this table (and should that be done with a query?). With eventual consistency it's perfectly possible for this data to be out of date, so how should I handle that?

Aucun commentaire:

Enregistrer un commentaire