2014-02-10 4 views
2

을 akka.io, 내가 아래에있는 application.conf 파일에 다음을 넣어 src/main/resources는 SBT 0.13 프로젝트에서 디스패처 구성 예외

application.conf : 지금

blocking-dispatcher { 
type = PinnedDispatcher 

executor = "thread-pool-executor" 
thread-pool-executor { 
core-pool-size-min = 2 
core-pool-size-factor = 2.0 
core-pool-size-max = 10 
} 
throughput = 100 
mailbox-capacity = -1 
mailbox-type ="" 
} 

나는 예외를 받고 있어요 배우를 만듭니다

object Main extends App { 

    implicit val system = ActorSystem() 

    val fileReaderActor = system.actorOf(Props(new FileReaderActor(fileName)).withDispatcher("blocking-dispatcher"), "fileReaderActor") 

} 

나는군요 :

Exception in thread "main" akka.ConfigurationException: Dispatcher [blocking-dispatcher] not configured for path akka://default/user/fileReaderActor 
    at akka.actor.LocalActorRefProvider.actorOf(ActorRefProvider.scala:714) 
    at akka.actor.dungeon.Children$class.makeChild(Children.scala:191) 
    at akka.actor.dungeon.Children$class.attachChild(Children.scala:42) 
    at akka.actor.ActorCell.attachChild(ActorCell.scala:338) 
    at akka.actor.ActorSystemImpl.actorOf(ActorSystem.scala:518) 
    at Main$delayedInit$body.apply(Main.scala:14) 
    at scala.Function0$class.apply$mcV$sp(Function0.scala:40) 
    at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12) 
    at scala.App$$anonfun$main$1.apply(App.scala:71) 
    at scala.App$$anonfun$main$1.apply(App.scala:71) 
    at scala.collection.immutable.List.foreach(List.scala:318) 
    at scala.collection.generic.TraversableForwarder$class.foreach(TraversableForwarder.scala:32) 
    at scala.App$class.main(App.scala:71) 
    at Main$.main(Main.scala:8) 
    at Main.main(Main.scala) 

무엇이 누락 되었습니까?

+1

IDE의 빌드 경로에 resources 디렉토리를 포함하는 것을 잊어 버린 것 같습니다. –

답변

2

먼저 설정이로드되는 것을 확인하십시오

System.out.println(system.settings()); 
// this is a shortcut for system.settings().config().root().render() 

는 여기에 대해 자세히 알아보기 : http://doc.akka.io/docs/akka/2.2.3/general/configuration.html#Logging_of_Configuration

둘째, 다음 구성은 실제로 의미가 없습니다.

blocking-dispatcher { 
    type = PinnedDispatcher 

    executor = "thread-pool-executor" 
    thread-pool-executor { 
     core-pool-size-min = 2 <----- Since you're using a PinnedDispatcher, it only uses 1 thread 
     core-pool-size-factor = 2.0 <----- same here 
     core-pool-size-max = 10 <----- same here 
    } <--- PinnedDispatcher will automatically make it 1 thread: https://github.com/akka/akka/blob/master/akka-actor/src/main/scala/akka/dispatch/PinnedDispatcher.scala#L27 
    throughput = 100 
    mailbox-capacity = -1 
    mailbox-type ="" 
} 
-1

당신은 너무

implicit val executionContext = system.dispatchers.lookup("blocking-dispatcher") 

같은 실행 컨텍스트 디스패처의 조회를 수행하고 ActorSystem이 ExecutionContext에 전달해야합니다. 문서에서

인용구 : If an ActorSystem is created with an ExecutionContext passed in, this ExecutionContext will be used as the default executor for all dispatchers in this ActorSystem. If no ExecutionContext is given, it will fallback to the executor specified in akka.actor.default-dispatcher.default-executor.fallback [1]

[1] http://doc.akka.io/docs/akka/snapshot/scala/dispatchers.html

+0

코멘트 주셔서 감사합니다하지만 ExecutionContext 함께 내 ActorSystem 만들지 않았습니다. 그리고 두 번째 질문 executionContext는 암시 적 변수입니다. 어떻게 전달해야합니까? –

관련 문제