I am trying to learn akka-http
and working on their example
Here is what my code looks like
val system = ActorSystem.create("enterpriseSystem", ConfigFactory.load("application"))
val notifier = system.actorOf(Props[Notifier], "notifier")
and Notifier as
class Notifier extends Actor with ActorLogging {
implicit val system = ActorSystem()
implicit val materializer = ActorMaterializer()
import scala.concurrent.ExecutionContext.Implicits.global
def receive = {
case CommunicateECFailure =>
log.info("notifying about EC Failure")
val responseFuture: Future[HttpResponse] =
Http().singleRequest(HttpRequest(uri = "http://localhost:8080"))
responseFuture onComplete {
case response =>
log.info("response received {}", response)
log.info("notified about EC Failure")
}
}
As you can see I create new ActorSystem
with every Actor
creation, is that bad? I read in akka docs that you should not have many ActorSystems
How can I avoid that? passing it as an argument during construction?