After the recent changes in Akka license, Scala developers are looking for an alternatives, especially for the akka-actors module. Actors allow race-free handling of mutable state without resorting to threads and locks. Key features of an actor that enables this use case are:

  1. Sequential processing of messages within an actor: this can be done using Executors.newSingleThreadExecutor
  2. Ability to spawn large number of actors on top of a handful JVM threads: this can be done using virtual-threads from Loom.

Combining these two, we will show how to do the following:

akka-actors provides a lot more features like supervision, fault tolerance and so on. But, those features may not be essential for your app. If so, following the pattern we described will simplify your code without having to deal with the licensing dilemma.