Akka dispatcher not configured exception in Play/Scala application

非 Y 不嫁゛ 提交于 2020-01-24 20:58:26

问题


I am doing a disk intensive operation and I want to use my own thread-pool for it and not the default one.

I read the following link, and I am facing the exact same problem Akka :: dispatcher [%name%] not configured, using default-dispatcher

But my config file is slightly different, I have tried the suggestion but it not working. My application.conf in play has the following

 jpa-execution-context {
  thread-pool-executor {
    core-pool-size-factor = 10.0
    core-pool-size-max = 10
  }
}

And then in my test code I do the following, but I get an exception. Here is the test method

private def testContext():Future[Int]  = {
val system = ActorSystem.create()
val a = ActorSystem.create()
implicit val executionContext1 = system.dispatchers.lookup("jpa-execution-context")
Future{logger.error("inside my new thread pool wonderland");10}{executionContext1}

}

Here is the exception:

akka.ConfigurationException: Dispatcher [jpa-execution-context] not configured

回答1:


I think you forgot a few elements in your configuration:

jpa-execution-context {
  type = Dispatcher
  executor = "thread-pool-executor"
  thread-pool-executor {
    core-pool-size-factor = 10.0
    core-pool-size-max = 10
  }
}

Doc link: http://doc.akka.io/docs/akka/current/scala/dispatchers.html#types-of-dispatchers



来源:https://stackoverflow.com/questions/46010824/akka-dispatcher-not-configured-exception-in-play-scala-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!