0
votes

I am trying to work with typed actors version 2.6.3 and akka http version 10.1.11 while all worked fine in non typed actors , now I am getting compilation error

object Main extends App {

   def createServer(implicit system: ActorSystem[IdentityCalculated]) = {

implicit val materializer = ActorMaterializer()

 }
 def apply(): Behavior[IdentityCalculated] = {
Behaviors.setup { context =>

  val identityManager = context.spawn(IdentityManager(), "identity-manager")

  implicit val timeout = Timeout(10, TimeUnit.SECONDS)
  implicit val scheduler = context.system.scheduler

  identityManager.tell(CalculateIdentity(context.self))

  Behaviors.receiveMessage{
    case IdentityCalculated(_,_,_) =>
      println("got response")
      Behaviors.same
  }
}

}
ActorSystem(Main(), "credentials-manager")

}

what am I missing? I want to create http server when I get the message that the identity was calculated how ever i am getting compilation error in the materializer creation

Main.scala:19:50: implicit ActorRefFactory required: if outside of an Actor you need an implicit ActorSystem, inside of an actor this should be the implicit ActorContext [error] implicit val materializer = ActorMaterializer() [error] ^ [error] one error found

thanks

3
If you hit a compilation error and want help about, indicating/pasting the trace is required.cchantep
added the exact errorli-raz

3 Answers

1
votes

You can use classic streams (which are typed, despite running on an untyped ActorSystem) by replacing:

implicit val materializer = ActorMaterializer()

with

implicit val materializer = system.classicSystem
1
votes

In Akka 2.6 the ActorMaterializer API has been deprecated and a new system wide materializer that is always available have been introduced. To run a stream you should only need the implicit ActorSystem[T] in scope.

akka-stream-typed is only needed if you want to use the specific stream operators for interacting with Akka typed actors (ActorSource, ActorFlow and ActorSink)

However the Akka HTTP APIs is still depending on the classic APIs so you may need to adapt them to be able to bind a HTTP endpoint for example.

If that is your issue, you can see how to do that in the Akka HTTP quickstart guide here: https://developer.lightbend.com/guides/akka-http-quickstart-scala/http-server.html

0
votes

I had to use akka-stream-typed and not akka-stream