Bulk update in CQRS

1,277 views
Skip to first unread message

Yoann Esnaud

unread,
Sep 21, 2010, 2:34:39 AM9/21/10
to ddd...@googlegroups.com
Hi all,

first, apologies if this question has been asked before.

I have an aggregate root called Task of which an admin user may decide to assign a certain type of task to a group of people. The number of tasks can be in the 100s. I am trying to find the best way to do this, and so how would you:

a. in the command object load up all of the AR of that certain task type?
b. would you then update every single AR?

Thanks for your help,

Regards,

Yoann.



seagile

unread,
Sep 21, 2010, 9:09:01 AM9/21/10
to DDD/CQRS
One command for each assignment to each person (or group if that's an
aggregate as well). You can batch those. A transaction boundary over
the lot of them would indicate a missing aggregate.

Nuno Lopes

unread,
Sep 21, 2010, 9:40:10 AM9/21/10
to ddd...@googlegroups.com
Hi,

>> I have an aggregate root called Task of which an admin user may decide to
>> assign a certain type of task to a group of people. The number of tasks can
>> be in the 100s. I am trying to find the best way to do this, and so how

It really depends what the underlying model for the management of these tasks.

Does the domain model captures the concept of TaskAssignee?

I mean:

A task can be assigned either to a Task Assignee (a Role of a Person in the context of Task Assignments), a Group of Task Assignee's (AssigneeGroups), or a combination of both.

TaskAssignee's can belong to AssigneeGroup.

If a TaskAssignee belong to an AssigneeGroup all tasks assigned to this group are assigned to all TaskAssignee's (Filters). Completion of a Task is then another Entity individual to each person.

Hope it helps,

Nuno

Chris Nicola

unread,
Jan 11, 2011, 5:27:41 PM1/11/11
to ddd...@googlegroups.com
So I'm resending this because for some reason you can't do a proper reply from a search in GG (sorry for sending twice Nuno).

So I think a more general answer is needed for this question and I'm going to pose a different example to see if it can help.  So again going from my product catalog example, lets say my commands look like this:

- CreateNewProduct
- SetProductFeatures
- RemoveProductFeatures
- AddProductToCategory
- RemoveProductFromCategory
etc. (speak up if you think these look like lame commands for some reason)

Now, lets say I get a bulk source of data on a regular basis that I want to use for doing updates of product data.  The way I see it I have the following approaches:

A)  Via some service layer I process the bulk data and for each product I create the necessary commands to add and update the products in my catalog.  This has the downside of creating multiple commands per update and multiple events.  It also isn't entirely representative of what the user performing the bulk update actually did.

B) I add two commands CreateNewProductFromBulk, UpdateProductFromBulk which contain more fields representing everything that a bulk update to a product can change the command handler then calls the appropriate behaviors again producing a series of events

C) I add the same commands as in B, however I map this to a new behavior on the domain model that produces a single event.  This seems to have the unfortunately side effect of introducing the concept of bulk updates to the domain model though where it doesn't feel like it belongs.

Perhaps, part of my concern comes from the handling of events.  I am working with MongoDB and each event will result in a separate and granular change to a single document which seems like excessive churn.  Perhaps there is simple a better way to handle updating my read model.

Chris
Reply all
Reply to author
Forward
0 new messages