2017-08-14 18 views
0

私はPlay 2.3.7を使用していますので、コントローラ内部からアクタを使用する必要があります。次のコードは、カスタムディスパッチャを検索できません

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

答えて

1

参考フルパス:

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 
    } 
} 
:あなたは、 system.dispatchers.lookup("foo-dispatcher")を使用 play名前空間の foo-dispatcher外を定義したい場合は

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

関連する問題