Check remembered entities before remembering entity (#25271)

* Check remembered entities before remembering entity

Messages that come through for an entity before StartEntity
has been processed for that entity caused redundant persistence
of the entity.
This commit is contained in:
Justin Peel 2018-07-10 09:24:52 -06:00 committed by Christopher Batey
parent 51e0bc2347
commit a05170c419

View file

@ -455,11 +455,15 @@ private[akka] trait RememberingShard { selfType: Shard ⇒
context.child(name) match {
case Some(actor)
actor.tell(payload, snd)
case None
//Note; we only do this if remembering, otherwise the buffer is an overhead
messageBuffers.append(id, msg, snd)
processChange(EntityStarted(id))(sendMsgBuffer)
if (state.entities.contains(id)) {
require(!messageBuffers.contains(id), s"Message buffers contains id [$id].")
getEntity(id).tell(payload, snd)
} else {
//Note; we only do this if remembering, otherwise the buffer is an overhead
messageBuffers.append(id, msg, snd)
processChange(EntityStarted(id))(sendMsgBuffer)
}
}
}