Why doesn't the Akka Persisence Query Read Journal retrieve my events?

那年仲夏 提交于 2019-12-06 12:07:15

With receiveRecover not doing the necessary state recovery work, persistence wouldn't work properly. I would suggest putting some basic state recovery logic in receiveRecover and have your updateState method cover also tagged event cases.

I used eventsByTag in an app with state recovery logic similar to the following and it worked fine on both fresh start and recovery.

def updateState(e: Any): Unit = e match {
  case evt: Event =>
    state = state.updated(evt)
  case Tagged(evt: Event, _) =>
    state = state.updated(evt)
}

...

override def receiveRecover: Receive = {
  case evt: Event => updateState(evt)
  case taggedEvt: Tagged => updateState(taggedEvt)
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!