无法查找自定义调度程序

Not able to lookup a custom dispatcher

我正在使用 Play 2.3.7,我需要使用控制器内部的 Actors。以下代码工作正常

implicit val system = ActorSystem()
implicit val dispatcher = system.dispatcher
val future = (IO(Http) ? Get(url).withHeaders(...).mapTo[HttpResponse]
val result = Await.results(future, Duration.Inf)

现在我对 conf/application.conf

进行以下更改
play {
  akka {
    actor {
      default-dispatcher {
        type = Dispatcher
        executor = "thread-pool-executor"
        thread-pool-executor {
          fixed-pool-size = 128
        }
      }
      foo-dispatcher {
        type = Dispatcher
        executor = "thread-pool-executor"
        thread-pool-executor {
          fixed-pool-size = 128
        }
      }
    }
  }
}

现在,将我的代码更改为

implicit val system = ActorSystem()
implicit val dispatcher = system.dispatchers.lookup("foo-dispatcher")
val future = (IO(Http) ? Get(url).withHeaders(...).mapTo[HttpResponse]
val result = Await.results(future, Duration.Inf)

我收到异常消息 [foo-dispatcher] not configured

引用完整路径:

implicit val dispatcher = system.dispatchers.lookup("play.akka.actor.foo-dispatcher")

如果您想使用 system.dispatchers.lookup("foo-dispatcher"),请在 play 命名空间之外定义 foo-dispatcher

play {
  akka {
    actor {
      default-dispatcher {
        type = Dispatcher
        executor = "thread-pool-executor"
        thread-pool-executor {
          fixed-pool-size = 128
        }
      }
    }
  }
}

foo-dispatcher {
  type = Dispatcher
  executor = "thread-pool-executor"
  thread-pool-executor {
    fixed-pool-size = 128
  }
}