ES, Multiple BCs and Ordering in Read Store

93 views
Skip to first unread message

Will Comeaux

unread,
May 21, 2013, 3:37:35 PM5/21/13
to ddd...@googlegroups.com
Hello all, my first post here.
I have read quite a few of the older posts - so if this is clearly answered somewhere I have not yet crossed it.

Given two BCs is it at all possible to create a read model in one BC that accurately represents the state of both - in an event sourced scenario?

Users Bounded Context - Manages user accounts, profiles, etc.
Orders Bounded Context - Manages orders.

In the Orders BC I have a read store that tracks order history - including any changes to user name, address, etc.

How would you write a read model in the Orders BC such that it shows the First + Last names of the user who made the order, at the time the order was made?

Do we replay events from both BCs into an aggregator, sort on date/time and then play then to the final read store?
Is there an easy way to guarantee ordering - I know Greg generally says we only guarantee ordering inside a single BC?
I realize that in most cases having timestamps that "clash" between BCs should not matter.
The read model should at least be deterministic, I can't play the events twice and get different results in the read store based on some non-deterministic ordering scenario.

Thoughts?
Thanks and great group you have here!

Will

Dan Normington

unread,
May 23, 2013, 12:50:28 PM5/23/13
to ddd...@googlegroups.com
The command could be hydrated with the information you speak of at the time the order is placed. Meaning your domain model would have the following information available to create an OrderSubmitted event.

OrderSubmitted
- OrderId
- CustomerId
- FirstName
- LastName
- Street
- City
- State
- Zip

What I'm guessing is that your event looks something more like this and your're trying to figure out where/how to get the customer information while populating your order history read model:

OrderSubmitted
- OrderId
- CustomerId
- ...

In this scenario you'd have to get the customer's information in your handler from some other read model, then populate your order history from that. I'll be honest I don't know what the best way is or if either are considered "standard". I think that the first example I provided might be the better option since this information would be presented to the customer during the time of order submittal. They would confirm their name, address etc. Once it is confirmed that information is packaged up in the command and sent on.



Will

--
You received this message because you are subscribed to the Google Groups "DDD/CQRS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dddcqrs+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages