BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Building a Reactive DDD and CQRS Based Application Using Akka

Building a Reactive DDD and CQRS Based Application Using Akka

This item in japanese

Lire ce contenu en français

The goal of Domain-Driven Design (DDD) is to decompose a complex business domain into manageable components taking into account scalability and consistency requirements, and is combined with CQRS great for building software based on concepts like bounded contexts, transaction boundaries and event based communication, Pawel Kaczor starts a three-part series building an reactive application based on these concepts and using Akka, an open-sourced platform for event-driven applications.

Pawel, an IT consultant currently involved in CQRS and Scala, states that consistency guaranteed by global transactions is an artificial requirement not addressing real requirements, not even for enterprise-class systems. To fully benefit from a DDD/CQRS architecture he suggests a change of the underlying technologies. For storage he suggests using NoSQL databases and when on the JVM platform Pawel suggests using Akka. A persistence module was recently released to handle persistable processes which make Pawel look at Akka as a platform for building enterprise applications.

Pawel starts his example building an event sourced aggregate root with Akka. An aggregate root should be modelled as a stateful actor that asynchronously accepts commands and produces events. When a command is accepted an event message is produced representing this fact and once the event is persisted an acknowledgment message is returned and the event is propagated.

In Akka an actor is created by another actor which then becomes its supervisor. This supervision pattern means a client's interaction can be simplified by using a single actor for creation of aggregate root actors. To end the lifecycle, an actor when finished processing and becoming idle it should ask its parent to be dismissed, or stopped.

For the query side, Pawel implements the infrastructure needed for working with projections. Two Akka modules are available; Akka Persistence, marked as experimental, supports the concept of projections and Akka Streams, currently under development, is an implementation of a recently announced standard for asynchronous stream processing on the JVM platform.

Pawel has made the source for his example available on github.

Rate this Article

Adoption
Style

BT