PersistenceQuery.get(actorSystem) with typed ActorSystem

Currently it seems not to be possible to get a PersistenQuery (or a ReadJournal) with a typed ActorSystem:

readJournal = PersistenceQuery.get(actorSystem).getReadJournalFor((Class<ReadJournal>) Class.forName(readJournalClassName), readJournalIdentifier);

I think this should be possible. Is there a way I don’t know?

You need to convert the akka.actor.typed.ActorSystem to akka.actor.ActorSystem, which is done with:

import akka.actor.typed.javadsl.Adapter;

Adapter.toClassic(actorSystem)

I see, thanks a lot for the quick response. The reason I opened an issue first in github for this is that I think it should be possible to get a read journal without this conversion. But for now this is sufficient for what I’m trying to do. Btw… I also found it in the docs now… sorry for bothering you.

Just some notes after trying it: it is actually not called Adapter.toClassic() it is called Adapter.toUntyped(). There is no toClassic() (at least in in Akka 2.5.26)

In the doc (Coexistence: https://doc.akka.io/docs/akka/current/typed/coexisting.html ) is an example with Adapter.toClassic() but this is used to convert an ActorRef:

second.tell(
              new Typed.Ping(context.getSelf().narrow()), Adapter.toClassic(context.getSelf()));

So this would mean that the example is wrong (I haven’t really tried it).

It was renamed. I recommend that you use version 2.6.0-RC, and you find the latest documentation at https://doc.akka.io/docs/akka/2.6/