Alex
Alex

Reputation: 8313

Akka message undelivered

I've a PropertiesStore actor that holds a mutable.Buffer of runtime configuration that's manipulated through a 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.

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 (i.e. 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. 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. [2] dead letters encountered. This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'

and I never receive my Property instance in the callee. The cameo (instance of PropertyLookup) does do its stuff and log, so I know that part is working.

What's happening? Is my cameo all wrong? Any better ways to do this? How do I understand what's happening around this warning>

Upvotes: 1

Views: 321

Answers (1)

Przemek Piotrowski
Przemek Piotrowski

Reputation: 7486

Is your code and log outputs up to date? First you gave definition of Read as

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. But your log output shows that this actor name doesn't contain "PropertiesLookup" string.

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.

Upvotes: 1

Related Questions