I'm struggling with aggregates in actor model (akka) and how to store their state. I wonder what role does repository stands for in actor model in DDD.

I have a situation, where my aggregate root creates another aggregate as result. But internally, AR firstly creates an actor and then sends additional messages to it in foreach cycle so newly created aggregate updates its state several times and then I need to store it's state.

1. I was thinking of registering "uncommitted changes" in aggregate, so in this case I could've sent GetUncommittedChanges() to this aggregate and receive the required data.

2. Second approach might be to keep reference to repository in aggregate, but I'm skeptical about this one. But the message to aggregate could be just: SaveYourself()

3. The third approach is maybe the cleanest: That every aggregate will publish event, and according to that hitting db multiple times? e.g. AggregateCreated(somedata), AggregateUpdated(additionalData), AggregateUpdated(..) 20 times...how to handle this properly?

  • Answering this is hard without seeing the code. Can you tell why your aggregate root have to create another aggregate as a result? Having a SaveYourself() method is definitely a bad idea. What I suggest is to create the Artist model, perform all the updates and then pass it to the repository to save it. Commented Jun 26, 2017 at 9:01
  • Please clarify: as a result of what action is the other aggregate root created?
    – marstato
    Commented Jun 26, 2017 at 9:05
  • @marstato The reason why aggregate root is creating another aggregate is because in other case, it would become heavy in time, so aggregate root cannot have list of entities, instead, its serves as a factory that creates new aggregates which contains identity of its "parent" - aggregate root.
    – Slimer
    Commented Jun 26, 2017 at 10:24
  • 1
    Then this is not the responsibility of the aggregate root; its the responsibility of the service that manages the aggregate root.
    – marstato
    Commented Jun 26, 2017 at 10:28
  • What exactly is responsibility of service managing the AR?
    – Slimer
    Commented Jun 26, 2017 at 12:10

1 Answer 1


The responsibility of the application service managing AR is to load and persist the aggregate. Also, it is responsible for publishing any domain events emitted as a result of change in the state of an aggregate.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.