6

When using Akka, CQRS style, is still there a place for Entities?

Or does everything now go to Aggregates, implemented as Actors + Value Objects.

I notice that most entities are written as mutable objects with side effects - this doesn't seem to jive well with Actor based style.

  • Either an Entity or an Aggregate may contain Value Objects. An Aggregate is an Entity that contains other Entities. With this in mind, the conclusion you seem to be drawing may be exactly backwards. – king-side-slide Mar 15 '18 at 19:52
0

Yes. In DDD an aggregate contains an aggregate root which is an entity, and one or more other objects which themselves may be both value objects and other entities (chapter 6 in Evans' blue book). How many entities as opposed to value objects your aggregates contain should depend entirely on the needs of your domain.

Your actors and CQRS aggregates do not need to map 1:1 to your domain aggregates. Instead consider what you need in terms of concurrency and where you want your transactional boundaries to be. A too granular actor system may suffer from large messaging overhead and be difficult to reason about, whereas one that is not granular enough may be too slow doing too many tasks sequentially or not be cohesive enough.

At the coarse end you can have actors that act as a service managing multiple aggregate roots, you can let each actor represent the aggregate root entity, and at the fine end, delegate responsibility in your aggregate to multiple actors.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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