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?