Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limiting the modification of one aggregate per transaction #54

Open
kosletr opened this issue May 29, 2024 · 2 comments
Open

Limiting the modification of one aggregate per transaction #54

kosletr opened this issue May 29, 2024 · 2 comments

Comments

@kosletr
Copy link

kosletr commented May 29, 2024

Hello! I really enjoyed the book and the papers. I have a question. As you also mentioned in the Effective Aggregate Design Part I: Modeling a Single Aggregate paper, a rule of thumb says that we should be limiting the modification of one aggregate per transaction. I am wondering why though? How does this rule of thumb help us? Why not persist two aggregates in the database under the same transaction? Thanks!

@kosletr
Copy link
Author

kosletr commented Jul 21, 2024

For example n com.saasovation.agilepm.application.team.TeamApplicationService.java the method changeTeamMemberEmailAddress modifies two aggregates, the ProductOwner and the TeamMember under the same transaction. Isn't this a violation of the rule of thumb?

@VaughnVernon
Copy link
Owner

VaughnVernon commented Jul 22, 2024

For example n com.saasovation.agilepm.application.team.TeamApplicationService.java the method changeTeamMemberEmailAddress modifies two aggregates, the ProductOwner and the TeamMember under the same transaction. Isn't this a violation of the rule of thumb?

Two reasons:

  1. There will be either the ProductOwner or a TeamMember updated, never both in the same transaction. The incoming event message from the Identity and Access Context doesn't contain a role name, just the user's email address. I decided to query both even though only one will be found, in order to simplify the single application service method. See:
  2. Email addresses are never changed in the Agile PM Context, only in the Identity and Access Context. Even if there were to be a single user playing both the ProductOwner and TeamMember roles, there would never be a collision. (I don't recall if there is a business rule to prevent one user playing multiple team roles.)

HTH.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants