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.

1
  • 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. Mar 15, 2018 at 19:52

1 Answer 1

1

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 and acknowledge that you have read and understand our privacy policy and code of conduct.

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