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)
有人可以解釋我有什麼不對嗎?