【问题标题】:Akka dispatcher not configured exception in Play/Scala applicationAkka 调度程序未在 Play/Scala 应用程序中配置异常
【发布时间】:2017-09-02 05:39:57
【问题描述】:

我正在执行磁盘密集型操作,我想使用我自己的线程池而不是默认线程池。

我阅读了以下链接,我遇到了完全相同的问题 Akka :: dispatcher [%name%] not configured, using default-dispatcher

但我的配置文件略有不同,我已经尝试过这个建议但它不起作用。 我在游戏中的application.conf 有以下内容

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

然后在我的测试代码中执行以下操作,但出现异常。这是测试方法

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

【问题讨论】:

    标签: scala playframework akka


    【解决方案1】:

    我认为您忘记了配置中的一些元素:

    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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多