thenativeweb / node-cqrs-domain

Node-cqrs-domain is a node.js module based on nodeEventStore that. It can be very useful as domain component if you work with (d)ddd, cqrs, eventdenormalizer, host, etc.
http://cqrs.js.org/pages/domain.html
MIT License
269 stars 57 forks source link

What is the purpose of `id` in a command? #129

Closed wi-ski closed 5 years ago

wi-ski commented 6 years ago

On this line: https://github.com/adrai/cqrs-sample/blob/master/domain/server.js#L17 we are defining some Id. But we also define the aggregateId. What is the purpose of id:? Is it supposed to change? Be static?

adrai commented 6 years ago

the command id identifies the command... it should be unique... it can be used to track the command accross the network or for possible deduplication etc...

wi-ski commented 6 years ago

:thinking: Is that like a correlation Id? Is there any reason not to use the name of the command? Like - have it be: "editAccount" instead of "as28-asd22-32222-91827"

adrai commented 6 years ago

the name of the command identifies the behaviour in your aggregate... it's not the identifier of that message... i.e. how do you distinguish 2 commands ('editAccount') that looks the same?

nanov commented 6 years ago

You could think of it as a request/transaction ID, it identifies this exact command "request", as a result a correlationId with the exact same ID is attached to the resulted event(s) and even further notification(s) ( ie. readmodel events ) for tracking/coupling ( extremely important when working with a message bus ).

wi-ski commented 6 years ago

Yasss. Ok. Thank you both. Awesome library. Im trying to marry it with: https://moleculer.services/0.12/docs/ and its been a blast. #overEngineeringForFun.