Are most commands actually events?

753 views
Skip to first unread message

Slava

unread,
Apr 28, 2012, 3:40:04 PM4/28/12
to ddd...@googlegroups.com
Still learning CQRS, but something odd struck me.

If I understand correctly, commands are requests to do something, vs events which indicate something happened. BUT, commands are eventually fulfilled requests if I use a queue.

In my specific case I'm building an inventory system for ecommerce store (physical items are in warehouse, but sold online).

Example of command where it's actually an event: a person (picker) picks an item off the shelf to ship it to fulfill an order. Well, if he finds an item, he's gonna pick it. I can try to validate his intent on the client, I might even query a view off the server to see if the item can be picked. But if server isn't available the item is picked (guy needs to continue to work), and system is eventually notified that the item was picked (messages queue on the client?). It's an event, not command. If the system doesn't like it, it needs to deal with the fact somehow (for example notify someone about the fact that item that wasn't available for picking was in fact picked).

Another example: customer support person talks on the phone with the customer who wants to reserve an item. On the client, on the spot, I can try to verify if there's an item available to reserve it (again, by querying the server). But if it gets validated on the client, customer support person tells the customer that item is reserved, and system gets an event message that an item is reserved. If by the time it processes the item isn't available anymore, it needs to deal with it. It can't just refuse an event. So, ReserveItem cannot be command. It must be an event (ItemReserved).

Another typical example: need to update address, Customer Moved vs. Correct Address (if it was mistyped). Well, customer moved is an event. System is notified about it. I can't do MoveUserToNewAddress command. I can only do AddressChangedDueToClientMoving event. Meanwhile Correct  Address sounds like a command.

So, to me it seems that in many cases the client will be issuing a lot of events about what's happening in the real world. Most validation that would prevent user from doing something (because it would violate a business rule) would need to happen on the client. We'll validate it on the server too, but will need to handle it as an event in many cases vs. it's a command on the client. By the time message gets to the server the user has already completed the action.

Am I missing something? Or do I understand what's going on correctly? Perhaps my point view is strongly influenced by the fact that the system I'm building models outside (physical) world (items, their location, online marketplace)?

Thank you. Slava Ivanyuk

Greg Young

unread,
Apr 28, 2012, 3:52:21 PM4/28/12
to ddd...@googlegroups.com
In most inventory systems there are no commands.
--
Le doute n'est pas une condition agréable, mais la certitude est absurde.

Slav Ivanyuk

unread,
Apr 28, 2012, 4:07:17 PM4/28/12
to ddd...@googlegroups.com

So, it seems if system models & tracks what's going on the outside (inventory system) it won't have commands.

 

If system actually manages data (off the top of my head, project management or bugs / issues tracker), then it'll rely on commands to allow users to modify the data.

 

Sounds about right?

gregor...@gmail.com

unread,
Apr 28, 2012, 5:00:52 PM4/28/12
to ddd...@googlegroups.com
Yes :)

Sent from my iPad
Reply all
Reply to author
Forward
0 new messages