Refactoring a bad actor to FSM

Now that we have recapped what actors are and understood some of the core features of the Akka actor system, it's time to dive in to our first big refactor. In the Chapter 1, Building a Better Reactive App, I called out the fact that the current implementation of the OrderManager was a poor use of an actor as it was mixing in too much usage of Futures.

This is a complicated actor, in that, it needs to fetch a bunch of data and then make various decisions on whether to stop or continue based on that data. When I end up with something like this, I usually turn to a finite-state machine (FSM) based actor. This is probably a different use case than what was originally intended or thought of as an FSM, but I think the ...

Get Mastering Akka now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.