Building a Reactive DDD and CQRS Based Application Using Akka

by Jan Stenberg on Jun 28, 2014 |

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


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

General Feedback
Marketing and all content copyright © 2006-2016 C4Media Inc. hosted at Contegix, the best ISP we've ever worked with.
Privacy policy

We notice you're using an ad blocker

We understand why you use ad blockers. However to keep InfoQ free we need your support. InfoQ will not provide your data to third parties without individual opt-in consent. We only work with advertisers relevant to our readers. Please consider whitelisting us.