Akka Classic
Akka Projections can be used with the new Actor API or the classic Actor API. The documentation samples show the new Actor API, and this page highlights how to use it with the classic Actor API.
Actor System
The ActorSystem
is a parameter in several places of the Projections API. That is the akka.actor.typed.ActorSystem
. Given a classic akka.actor.ActorSystem
it can be adapted to an akka.actor.typed.ActorSystem
like this:
- Scala
-
source
import akka.actor.typed.scaladsl.adapter._ private val system = akka.actor.ActorSystem("Example") private val typedSystem: akka.actor.typed.ActorSystem[_] = system.toTyped
- Java
-
source
import akka.actor.typed.javadsl.Adapter; akka.actor.ActorSystem system = akka.actor.ActorSystem.create("Example"); ActorSystem<Void> typedSystem = Adapter.toTyped(system);
PersistentActor
Events from Akka Classic Persistence can be emitted from PersistentActor
and consumed by a Projection with the EventSourcedProvider
EventSourcedProvider
. The events from the PersistentActor
must be tagged by wrapping them in akka.persistence.journal.Tagged
, which can be done in the PersistentActor
or by using Event Adapters.
Running
As described in Running a Projection the Projection is typically run with a Sharded Daemon Process. ShardedDaemonProcess
can be used in the same way with a classic akka.actor.ActorSystem
, after adapting it to akka.actor.typed.ActorSystem
as described above.
To run with a local actor the ProjectionBehavior
can be spawned from the classic ActorSystem
or a classic Actor
: