How to mix typed and untyped actors?

How do I mix typed and untyped actors? As I understand it, I have to specify the main actor when I create an instance of ActorSystem , like this

 val system: akka.typed.ActorSystem[Start] = akka.typed.ActorSystem("main", Props(mainBehaviour)) 

On the other hand, I use akka-http, which is initialized as follows

 implicit val system = ActorSystem() implicit val executor = system.dispatcher implicit val materializer = ActorMaterializer() // etc... 

I see that I can create a typed system from an untyped system by calling

 object ActorSystem { def apply(untyped: akka.actor.ActorSystem): ActorSystem[Nothing] = new Wrapper(untyped.asInstanceOf[ExtendedActorSystem]) } 

So, suppose I did

 val typeSystem = akka.typed.ActorSystem(untypedSystem) 

How to create your first typed actor from typeSystem ? Printed ActorContext that actorOf I can call.

Other materials that I read on this subject

+7
scala actor akka akka-typed
source share
1 answer

Good trick, this is not convenient at the moment: you will need to create an ActorSystem typed system and then access the basic untyped HTTP extension, but the underlying method is private[akka] , you can access it by placing it in your project helper code in the Akka namespace, or you can go the other way around:

 implicit val untyped = akka.actor.ActorSystem("main") import untyped.dispatcher implicit val mat = ActorMaterializer() import akka.typed.Ops._ val typedRef = untyped.spawn(Props(mainBehaviour)) val typedSys = ActorSystem(untyped) Http().bind(...) // and send things to typed 
+3
source share

All Articles