2017-02-15 182 views
0

我创建了我的自定义邮箱,名为CustomMailBox,它源自MyUnboundedMessageQueueSemantics特质。然后我把这个配置到application.conf:自定义akka邮箱配置(斯卡拉)

custom-dispatcher { 
    mailbox-requirement = 
    "com.MyUnboundedMessageQueueSemantics" 
} 

akka.actor.mailbox.requirements { 
    "com.MyUnboundedMessageQueueSemantics" = 
    custom-dispatcher-mailbox 
} 

custom-dispatcher-mailbox { 
    mailbox-type = "com.CustomMailBox" 
} 

akka.actor.deployment { 
    /myactor { 
    dispatcher = custom-dispatcher 
    } 
} 

之后,我创造我的演员是这样的:

val system = ActorSystem("mySystem") 
val quadrocopter = system.actorOf(Quadrocopter.props(vrep, clientID, handler) 
     .withDispatcher("custom-dispatcher"), "myactor") 

和运行我的程序后,我得到这个错误:

Exception in thread "main" akka.ConfigurationException: Dispatcher [custom-dispatcher] not configured for path akka://mySystem/user/myactor 
    at akka.actor.LocalActorRefProvider.actorOf(ActorRefProvider.scala:758) 
    at akka.actor.dungeon.Children$class.makeChild(Children.scala:273) 
    at akka.actor.dungeon.Children$class.attachChild(Children.scala:46) 
    at akka.actor.ActorCell.attachChild(ActorCell.scala:374) 
    at akka.actor.ActorSystemImpl.actorOf(ActorSystem.scala:732) 
    at Simulation$.delayedEndpoint$Simulation$1(Simulation.scala:24) 
    at Simulation$delayedInit$body.apply(Simulation.scala:12) 
    at scala.Function0$class.apply$mcV$sp(Function0.scala:34) 
    at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12) 
    at scala.App$$anonfun$main$1.apply(App.scala:76) 
    at scala.App$$anonfun$main$1.apply(App.scala:76) 
    at scala.collection.immutable.List.foreach(List.scala:381) 
    at scala.collection.generic.TraversableForwarder$class.foreach(TraversableForwarder.scala:35) 
    at scala.App$class.main(App.scala:76) 
    at Simulation$.main(Simulation.scala:12) 
    at Simulation.main(Simulation.scala) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:498) 
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147) 

有人可以解释我有什么不对吗?

回答

0

问题通过在配置文件中更改/myactor" */myactor"解决。 第二步是创建actor时删除调用withDispatcher()函数。