Reactive Messaging Patterns with the Actor Model

I recently finished reading Vaughn Vernon’s book Reactive Messaging Patterns with the Actor Model. The book is about how to use the Actor model with Scala and the Akka toolkit.

First three chapters of the book concentrate on giving the reader a quick introduction to Scala, Actor Model and Akka. Personally I enjoyed these three chapters the most in this book. They we’re quick to read and provided so much information for me as I had no previous experience with neither Akka or the Actor Model.

Bulk of the book is the chapters following the first three that are messaging patterns inspired by Enterprise Integration Patterns. Thus the last seven chapters are basically a pattern catalog. This is something I have heard critique from few other people, especially people who have read Enterprise Integration Patterns (I haven’t, yet). I admit pattern catalogs are heavy to read and I too struggled with reading the quite intensive examples. But, these also provided me with the most practical knowledge of Akka and the Actor Model. I made use of some of the things I learned in the catalog almost right away when I did some exercise programs with the Akka toolkit. There is some really good stuff in there.

One thing I found especially interesting was the Transactional Actor pattern in Chapter 9.  This pattern explains how to persist actor state with Event Sourcing and thus gives some insight on how to use actors to implement Aggregates. This is something I am planning to try out in the future. Event Sourcing is a really natural fit for persisting actors so I’m looking forward to playing with this.

It’s a shame that Akka Streams were still in the planning phase when the book was written, this is something I would like to learn more of at some point. The book covers PersistentView very shortly, these can be used to denormalize persisted actor state for use in view logic. This is something I would have liked to have seen a more thorough example of in the book. It is still a bit unclear to me how to denormalize actor the state for view logic in practice, but apparently Akka Streams is the correct way to it now(?)

Even though I do not use Scala at work, I learned new things to consider in other environments as well. Most prominent at this time is the differentiation between types of messages. Consciously separating Command Messages, Event Messages and Document Messages is something I have concentrated on when using JavaScript event/messaging libraries. It’s interesting how learning unrelated technologies always seems to  teach something that’s useful event if you cannot use the technology itself.

TL;DR; I liked the book. Some chapters heavy to read, but provide valuable information. Read if you are interested in Scala and Akka.