Play/Scala应用程序中未配置Akka调度程序的异常 [英] Akka dispatcher not configured exception in Play/Scala application
问题描述
我正在执行磁盘密集型操作,因此我想使用自己的线程池而不是默认线程池.
I am doing a disk intensive operation and I want to use my own thread-pool for it and not the default one.
我阅读了以下链接,并且遇到了完全相同的问题 Akka ::未配置,使用default-dispatcher的调度程序[%name%]
I read the following link, and I am facing the exact same problem Akka :: dispatcher [%name%] not configured, using default-dispatcher
但是我的配置文件略有不同,我已经尝试了建议,但是不起作用.
我在玩的application.conf
具有以下内容
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}
}
这里是个例外:
akka.ConfigurationException: Dispatcher [jpa-execution-context] not configured
推荐答案
我认为您忘记了配置中的一些元素:
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
}
}
文档链接: http://doc.akka.io/docs/akka/current/scala/dispatchers.html#types-of-dispatchers
这篇关于Play/Scala应用程序中未配置Akka调度程序的异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!