我有PersistenceActor
并且我想在其preRestart
方法中做一些事情,基于导致重启的消息。对于常规演员来说很容易,因为有消息传递给preRestart
方法:
def preRestart(reason: Throwable, message: Option[Any])
然而,PersistentActor
无法以这种方式完成,因为每次None
都作为消息属性传递。它是由Eventsourced.scala
:
override protected[akka] def aroundPreRestart(reason: Throwable, message: Option[Any]): Unit = {
try {
internalStash.unstashAll()
unstashAll(unstashFilterPredicate)
} finally {
message match {
case Some(WriteMessageSuccess(m, _)) ⇒
flushJournalBatch()
super.aroundPreRestart(reason, Some(m))
case Some(LoopMessageSuccess(m, _)) ⇒
flushJournalBatch()
super.aroundPreRestart(reason, Some(m))
case Some(ReplayedMessage(m)) ⇒
flushJournalBatch()
super.aroundPreRestart(reason, Some(m))
case mo ⇒
flushJournalBatch()
super.aroundPreRestart(reason, None)
}
}
}
有谁知道为什么None
在那里传递,丢失了原始信息?
答案 0 :(得分:1)
这似乎是一种疏忽,我们应该在Akka中解决这个问题,我已经开了一张票来跟踪修复它:https://github.com/akka/akka/issues/21824