Return generated id of fresh new aggregate. #329
Unanswered
grzybsonssg
asked this question in
Q&A
Replies: 1 comment
-
|
Generating ids when handling commands is not the best idea. Why? Because it makes the code not idempotent. If for any reason the command is retried, you get two distinct ids for the same thing. Definitely not something you want. If you really want to generate identity in the command handler, you can add it to state and then look at the value returned by |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have a case when I want to generate ID of aggregate in my service code. But then, somehow I need to return it to client, so it can further interact with that aggregate. Here is a simple example of what I need:
In such configuration, when I call
Handleon command service, it will returnCardState. SinceWhat should I do? I don't want the
CardIdto be generated by client itself. MaybeAggregateIdshould be accessible through aggregate / aggregate state? What am I missing?Beta Was this translation helpful? Give feedback.
All reactions