尝试使持久性actor要求带有RequiresMessageQueue的自定义邮箱时出错 [英] Error trying to make a persistent actor require a custom mail box with RequiresMessageQueue
问题描述
我尝试以下操作:
class ClientActor (stockActor: ActorSelection, paymentsActor: ActorSelection) extends PersistentActor
with AtLeastOnceDelivery with akka.actor.ActorLogging with RequiresMessageQueue[akka.custom.CustomMailbox]{
//actor implementation
}
我得到了错误:
illegal inheritance;
self-type Shopping.ClientActor does not conform to akka.dispatch.RequiresMessageQueue[akka.custom.CustomMailbox]'s selftype akka.dispatch.RequiresMessageQueue[akka.custom.CustomMailbox]
with AtLeastOnceDelivery with akka.actor.ActorLogging with RequiresMessageQueue[akka.custom.CustomMailbox]{
AtLeastOnceDelivery一个非持久性参与者:
The same works with a non persistent actor:
class PaymentsActor extends Actor with akka.actor.ActorLogging with RequiresMessageQueue[akka.custom.CustomMailbox] {
// actor implementation
}
推荐答案
跟踪相关源代码, PersistentActor
扩展了 Eventsourced
,后者扩展了 PersistenceStash 依次扩展了< a href = https://github.com/akka/akka/blob/v2。 5.20 / akka-actor / src / main / scala / akka / actor / Stash.scala#L56 rel = nofollow noreferrer>特质藏匿:
Tracing the relevant source code, PersistentActor
extends Eventsourced
which extends PersistenceStash which, in turn, extends trait Stash:
trait Stash extends UnrestrictedStash with RequiresMessageQueue[DequeBasedMessageQueueSemantics]
在源代码中:
请注意,
Stash
特性只能一起使用对于演员,
具有基于双端队列的邮箱。默认情况下,基于存储的参与者请求基于$ deb的基于Deque的邮箱,因为存储特征扩展了
RequiresMessageQueue [DequeBasedMessageQueueSemantics]
。
您可以覆盖通过配置
请求
DequeBasedMessageQueueSemantics
时提供的默认邮箱...
Note that the
Stash
trait can only be used together with actors that have a deque-based mailbox. By default Stash based actors request a Deque based mailbox since the stash trait extendsRequiresMessageQueue[DequeBasedMessageQueueSemantics]
. You can override the default mailbox provided whenDequeBasedMessageQueueSemantics
are requested via config ...
一种方法是配置您的自定义邮箱,类似于源代码注释中所建议的内容:
One approach would be to configure your custom mailbox similar to what is suggested in the source code remarks:
akka.actor.mailbox.requirements {
"akka.dispatch.BoundedDequeBasedMessageQueueSemantics" = your-custom-mailbox
}
这篇关于尝试使持久性actor要求带有RequiresMessageQueue的自定义邮箱时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!