VIP Query Store
CHALLENGES
#1 Message order
Example:
IShopItemQuantityChanged
{ Quantity: 15, PublishedTime: 2013-05-20 04:31 }
{ Quantity: 10, PublishedTime: 2013-05-20 04:30 }
{
Quantity: 5
MetaInfo: {
Version: 1
FieldChanges: {
Quantity: 2013-05-20 04:30
}
}
}
{ Quantity: 15, PublishedTime: 2013-05-20 04:31 }
{
Quantity: 15
MetaInfo: {
Version: 2
FieldChanges: {
Quantity: 2013-06-07 04:31
}
}
}
{
Quantity: 15
MetaInfo: {
Version: 2
FieldChanges: {
Quantity: 2013-06-07 04:31
}
}
}
ChallEnges
#2 Update message before create
Example:
CreateAuction PublishedTime: 2013-06-27 04:30
UpdateDescription PublishedTime: 2013-06-27 04:33
Challenges
#3 Messages can be received more than once
IItemAdditionalDescriptionAdded: {
Description: "Addendum 1",
PublishedTime: 2013-06-27 04:30,
MessageId: "FBCE65B5-8392-45AB-884C-BC24910B5BFE"
}
IItemAdditionalDescriptionAdded: {
Description: "Addendum 1",
PublishedTime: 2013-06-27 04:30
MessageId: "FBCE65B5-8392-45AB-884C-BC24910B5BFE"
}
Same message received twice or different?
{
AdditionalDescriptions: [
"Addendum 1"
],
MetaInfo: {
Version: 2
FieldChanges: {
..
},
HandledMessages: [
"348C6FF1-CEE7-4031-9C39-A72C3DE95E67"
]
}
}
IItemAdditionalDescriptionAdded: {
Description: "Addendum 1",
PublishedTime: 2013-06-27 04:30
MessageId: "FBCE65B5-8392-45AB-884C-BC24910B5BFE"
}
Can now detect that message was already handled!
Concurrency
Concurrent write to same document
{
......
MetaInfo: {
Version: 2
FieldChanges: {
..
},
HandledMessages: [
...
]
}
}
var query = Query.And(
Query.EQ(x => x.ItemId, id),
Query.EQ(x => x.MetaInfo.Version, ViewModel.MetaInfo.Version) ←
);
Initializer
Requirements
-
Create initial state
- Add missing (new) properties
- Correct state (if a bug is identified)
Initializer
- Reads data from master data
- Creates init command messages that are sent to denormalizer
Advantages
-
Init commands are handled as any message update
- Uses the same update pipeline and concurrent write protection
- Can be run at the same time as normal messages are handled
- Can be executed multiple times without having to clear mongo store.
VIP Query Store
By torkelo
VIP Query Store
- 919