[英]Setting Bounded mailbox for an actor that uses stashing
I have an actor that depends on stashing. 我有一个依靠藏匿的演员。 Stashing requires
UnboundedDequeBasedMailbox
. Stashing需要
UnboundedDequeBasedMailbox
。 Is it possible to use stashing together with Bounded
mailbox ? 是否可以与
Bounded
邮箱一起使用存储?
As Arnaud pointed out, my setup is : 正如Arnaud指出的那样,我的设置是:
Actor with UnrestrictedStash with RequiresMessageQueue[BoundedDequeBasedMessageQueueSemantics]
and configuration : 和配置:
akka {
loggers = ["akka.event.slf4j.Slf4jLogger"]
loglevel = INFO
daemonic = on
actor {
mailbox {
bounded-deque-based {
mailbox-type = "akka.dispatch.BoundedDequeBasedMailbox"
mailbox-capacity = 2000
mailbox-push-timeout-time = 5s
}
requirements {
"akka.dispatch.BoundedDequeBasedMessageQueueSemantics" = akka.actor.mailbox.bounded-deque-based
}
}
}
}
And the error is : 错误是:
[ERROR] 2013/12/06 14:03:58.268 [r-4] a.a.OneForOneStrategy - DequeBasedMailbox required, got: akka.dispatch.UnboundedMailbox$MessageQueue
An (unbounded) deque-based mailbox can be configured as follows:
my-custom-mailbox {
mailbox-type = "akka.dispatch.UnboundedDequeBasedMailbox"
}
akka.actor.ActorInitializationException: exception during creation
at akka.actor.ActorInitializationException$.apply(Actor.scala:218) ~[akka-actor_2.10-2.2.0.jar:2.2.0]
at akka.actor.ActorCell.create(ActorCell.scala:578) ~[akka-actor_2.10-2.2.0.jar:2.2.0]
at akka.actor.ActorCell.invokeAll$1(ActorCell.scala:425) ~[akka-actor_2.10-2.2.0.jar:2.2.0]
at akka.actor.ActorCell.systemInvoke(ActorCell.scala:447) ~[akka-actor_2.10-2.2.0.jar:2.2.0]
at akka.dispatch.Mailbox.processAllSystemMessages(Mailbox.scala:262) ~[akka-actor_2.10-2.2.0.jar:2.2.0]
at akka.dispatch.Mailbox.run(Mailbox.scala:218) ~[akka-actor_2.10-2.2.0.jar:2.2.0]
at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:386) [akka-actor_2.10-2.2.0.jar:2.2.0]
at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260) [scala-library-2.10.2.jar:na]
at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339) [scala-library-2.10.2.jar:na]
at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979) [scala-library-2.10.2.jar:na]
at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107) [scala-library-2.10.2.jar:na]
Caused by: akka.actor.ActorInitializationException: DequeBasedMailbox required, got: akka.dispatch.UnboundedMailbox$MessageQueue
An (unbounded) deque-based mailbox can be configured as follows:
my-custom-mailbox {
mailbox-type = "akka.dispatch.UnboundedDequeBasedMailbox"
}
at akka.actor.ActorInitializationException$.apply(Actor.scala:218) ~[akka-actor_2.10-2.2.0.jar:2.2.0]
at akka.actor.UnrestrictedStash$class.$init$(Stash.scala:82) ~[akka-actor_2.10-2.2.0.jar:2.2.0]
at com.fg.mail.smtp.index.Indexer.<init>(Indexer.scala:38) ~[classes/:na]
at com.fg.mail.smtp.Supervisor$$anonfun$preStart$1.apply(Supervisor.scala:20) ~[classes/:na]
at com.fg.mail.smtp.Supervisor$$anonfun$preStart$1.apply(Supervisor.scala:20) ~[classes/:na]
at akka.actor.CreatorFunctionConsumer.produce(Props.scala:369) ~[akka-actor_2.10-2.2.0.jar:2.2.0]
at akka.actor.Props.newActor(Props.scala:323) ~[akka-actor_2.10-2.2.0.jar:2.2.0]
at akka.actor.ActorCell.newActor(ActorCell.scala:534) ~[akka-actor_2.10-2.2.0.jar:2.2.0]
at akka.actor.ActorCell.create(ActorCell.scala:560) ~[akka-actor_2.10-2.2.0.jar:2.2.0]
... 9 common frames omitted
If I do Props.withMailbox("bounded-deque-based")
then I get 如果我做
Props.withMailbox("bounded-deque-based")
那么我得到
Caused by: akka.ConfigurationException: Mailbox Type [bounded-deque-based] not configured
ANSWER : thanks to Arnaud : The problem was the configuration, bounded-deque-based config block should be at the same level as akka config block. 答案:感谢Arnaud:问题是配置,基于bounded-deque的配置块应该与akka配置块处于同一级别。 Documentation is totally misleading in this case...
在这种情况下, 文档完全是误导性的......
akka {
loggers = ["akka.event.slf4j.Slf4jLogger"]
loglevel = INFO
daemonic = on
actor {
mailbox {
requirements {
"akka.dispatch.BoundedDequeBasedMessageQueueSemantics" = akka.actor.mailbox.bounded-deque-based
}
}
}
}
bounded-deque-based {
mailbox-type = "akka.dispatch.BoundedDequeBasedMailbox"
mailbox-capacity = 2000
mailbox-push-timeout-time = 5s
}
According the official Akka stash doc you can decide to use a Stash trait that does not enforce any mailbox type see UnrestrictedStash . 根据官方Akka 存储文档,您可以决定使用不强制执行任何邮箱类型的Stash特征,请参阅UnrestrictedStash 。
If you use UnrestrictedStash you can configure manually the proper mailbox as long as it extends the akka.dispatch.DequeBasedMessageQueueSemantics marker trait. 如果使用UnrestrictedStash,只要它扩展了akka.dispatch.DequeBasedMessageQueueSemantics标记特征,您就可以手动配置正确的邮箱。
You can manually configure your BoundedMailbox mailbox following the mailboxes doc with something like : 您可以在邮箱doc之后手动配置BoundedMailbox邮箱,例如:
bounded-mailbox {
mailbox-type = "akka.dispatch.BoundedDequeBasedMailbox"
mailbox-capacity = 1000
mailbox-push-timeout-time = 10s
}
akka.actor.mailbox.requirements {
"akka.dispatch.BoundedDequeBasedMessageQueueSemantics" = bounded-mailbox
}
I did not try it myself but it should work. 我自己没有尝试,但它应该工作。
Edit : what version of Akka are you using? 编辑:您使用的是什么版本的Akka? Looks like the stash trait definition changed with the version 2.2.0
看起来隐藏特征定义随版本2.2.0而改变
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.