Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6913575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:14:10+00:00 2026-05-27T09:14:10+00:00

I have a simple examle domain of two aggregate roots and one regular entity.

  • 0

I have a simple examle domain of two aggregate roots and one regular entity.
Tenant, UserGroup and User where in this particular sample the Tenant and User make up for the two AggregateRoots.

When a command is received from the UI/Service layer it reaches the command handler which manipulates the write only domain.

You could say that User isn’t supposed to be an AggregateRoot at all but since it will be referenced by others, it cannot be a regular entity. (yes?)

These two AggregateRoots need to communicate. A User cannot be created without belonging to a UserGroup, which is an entity in the bounded context of Tenant. Presumably, we can create, since it is a simple constraint, a User through the constructor. User.Create(TenantId, UserGroupId)

It generates a DomainEvent with Date, AggregateVersion and AggregateId (of the user). Now we get to the blurry parts.

Open committing this event into the store, this event is broadcasted onto the bus (memory, whatever). It this the point where domain’s event handlers, similar to command handlers, catch the user created and notify/manipulate the Tenant‘s UserGroup to add the UserId?

Are my thoughts about solving this going into the entirely wrong direction?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T09:14:11+00:00Added an answer on May 27, 2026 at 9:14 am

    A Saga might be what you are looking for.

    Simply put: A saga can be implemented as an event handler that listens for specific events and issues commands to different aggregate roots, or even across context boundaries.

    In your case it might look like this:

    public class RegisterUserSaga : Handles<UserCreated>
    {
        public void Handle<UserCreated>(UserCreated evnt) {
            var tenantId = // you probably know how to find this
            var groupId =  // same here
            var command = new RegisterUserForTenant(evnt.UserId, tenantId, groupId);
            Bus.Send(command);
        }
    }
    

    Read more about sagas in this article by Rinat Abdullin or watch “CQRS, race conditions, and sagas – oh my!” by Udi Dahan

    Update:

    After our extended discussion in the comments I’ll try to show how this could work from a different angle (pseudo code ahead). This hopefully sheds some more light on a possible solution:

    // Aggregates:
    
    Tenant
        Guid TenantId
        List<Guid> UserGroups
    
    UserGroup
        Guid UserGroupId
        List<Guid> Users
    
    User
        Guid UserId
        Some more details
    
    // Commands:
    
    RequestRegistration(userId, userGroupId, user details)
    CreateUser(userId, user details)
    AddUserToGroup(userId, userGroupId)
    
    // The initial command would be:
    
    RequestRegistration (leading to a RegistrationRequested event)
    
    // The Saga handles the RegistrationRequested and all subsequent events
    
    UserRegistrationSaga 
        Handle(RegistrationRequested)
        -> send CreateUser command (which eventually leads to a UserCreated event)
        Handle(UserCreated)
        -> send AddUserToGroup command (-> UserAddedToGroup event)
        Handle(UserAddedToGroup)
        -> Done
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this simple example I can't seems to get working : MERGE INTO
I have this simple example: using System; using System.Collections.Generic; namespace ConsoleApplication1 { class Program
I have this very simple example that I am using to learn structs in
A simple example: Let's say I have one alias being sourced somewhere as: alias
Have a look a this simple example. I don't quite understand why o1 prints
i have simple regular expression: ^123$ Matches are for example 123 1234 etc. How
This is one of those scenarios where Paralysis by Analysis seems to have taken
I'm still learning about DDD and I have these two (probably simple) questions: If
This is a weird one I know. I'm trying to tie together two Rails
I have a simple .htaccess which redirect non www to www domain RewriteEngine on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.