[英]Akka message undelivered
I've a PropertiesStore
actor that holds a mutable.Buffer
of runtime configuration that's manipulated through a rest API. 我有一个
PropertiesStore
actor,它包含一个mutable.Buffer
的运行时配置,该mutable.Buffer
是通过rest API操作的。 You read and write from said store using these objects: 您可以使用以下对象在所述商店中读写:
Read(None, Property(key ="MyConfigKey", value = None))
to which the store responds with the Property
and its value. 商店以该
Property
及其值响应的方式。
In order to ease the locating of this store, I have another actor (a cameo) that I create on the fly: 为了简化此商店的定位,我有一个动态创建的其他演员(客串):
object PropertyLookup {
def apply(propertyKey: String, target: Option[ActorRef]): Props = {
Props(new PropertyLookup(propertyKey, target))
}
}
class PropertyLookup(key: String, target: Option[ActorRef]) extends Actor with ActorLogging {
val PropertiesStore = "/user/Master/DataStore/PropertiesStore"
val propertiesActor = context.actorSelection(PropertiesStore)
def receive: Actor.Receive = {
case _=>
log.info(s"Looking up ${key} via ${propertiesActor}")
propertiesActor.tell(Read(None, Property(key, None)), target.getOrElse(sender()))
log.info(s"Sent property lookup to PropertiesStore: ${key}")
// context.stop(self)
}
}
Which enables me to keep the "locating" of said actor (ie via its path) in one place, avoiding too much rework if it's moved. 这使我能够将角色的“定位”(即通过角色的路径)保持在一个位置,如果移动,避免了过多的返工。 This
PropertyLookup
has an optional target actor that the PropertiesStore
will send the result to once the lookup is performed. 此
PropertyLookup
具有一个可选的目标actor,一旦执行查找, PropertiesStore
会将结果发送到该对象。 I use all this like so in another actor to get a config value before I do some work: 在做一些工作之前,我在所有其他角色中都使用了类似的方法:
context.actorOf(PropertyLookup(PropertyKeys.SpreadsheetURL, None), s"PropertiesLookup_${self.path.name}") ! None
but when I do so, I get the following warning: 但是当我这样做时,会收到以下警告:
Message [domain.Read] from Actor[akka://NN/user/$a/Master/DataStore/PlayerStore#-1100303450] to Actor[akka://NN/user/Master/DataStore/PropertiesStore] was not delivered.
没有从Actor [akka:// NN / user / $ a / Master / DataStore / PlayerStore#-1100303450]发送给Actor [akka:// NN / user / Master / DataStore / PropertiesStore]的消息[domain.Read]。 [2] dead letters encountered.
[2]遇到死信。 This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'
可以使用配置设置“ akka.log-dead-letters”和“ akka.log-dead-letters-during-shutdown”关闭或调整此日志记录
and I never receive my Property instance in the callee. 而且我从没在被调用方收到我的Property实例。 The cameo (instance of
PropertyLookup
) does do its stuff and log, so I know that part is working. 客串(
PropertyLookup
实例)确实完成了它的工作并记录了日志,因此我知道该部分正在工作。
What's happening? 发生了什么? Is my cameo all wrong?
我的客串全都错了吗? Any better ways to do this?
还有更好的方法吗? How do I understand what's happening around this warning>
我如何理解此警告周围发生的事情>
Is your code and log outputs up to date? 您的代码和日志输出是否最新? First you gave definition of Read as
首先,您将Read定义为
Read(Property(key ="MyConfigKey", value = None))
but then you are using it as 但随后您将其用作
Read(None, Property(key, None))
Secondly you are creating actor with "PropertiesLookup_${self.path.name}" in name. 其次,您将以名称“ PropertiesLookup _ $ {self.path.name}”创建演员。 But your log output shows that this actor name doesn't contain "PropertiesLookup" string.
但是您的日志输出显示此参与者名称不包含“ PropertiesLookup”字符串。
In addition, notice that your path as logged includes a $a
which suggests that an anonymous actor is in fact in the path, which isn't what's in your actorSelection
call. 另外,请注意,记录的路径中包含
$a
,这表明该路径中实际上存在一个匿名actor,而不是actorSelection
调用中的内容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.