DEV Community

Discussion on: Immediate Consistency in Event Sourcing

Collapse
 
merrion profile image
Merrion-Duncan Jones

Another way to do this is to have a pre-populated set of unique identifiers (per category) in a FIFO queue and just have the book creation command take the next unique identifier off the queue.

That way your "uniqueness test" can run before the important time dependent and money generating functions of adding the book.

Collapse
 
barryosull profile image
Barry O Sullivan

I hadn't thought of that. There's nothing in the constraint that says the number can't be generated before the book. A queue is a really nice solution to that problem.

Collapse
 
merrion profile image
Merrion-Duncan Jones

The prepopulated queue of unique ids is a good solution for massively distributed systems as you can split the queue by region.