Building a Reactive DDD and CQRS Based Application Using Akka

| by Jan Stenberg Follow 34 Followers on Jun 28, 2014. Estimated reading time: 1 minute |

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 Stage

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread


Login to InfoQ to interact with what matters most to you.

Recover your password...


Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.


More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.


Stay up-to-date

Set up your notifications and don't miss out on content that matters to you