当前位置: 首页 > 知识库问答 >
问题:

如何在无根本原因的Akka持久性中调试JournalFailureException

宗乐池
2023-03-14

我正在试着调试下面的错误信息,由于错误不是打印出来的根本原因,所以很难调试这里的问题是什么。我尝试改变超时,但问题似乎没有恢复。

  Supervisor StopSupervisor saw failure: Exception during recovery. Last known sequence number [0]. PersistenceId [first], due to: Replay timed out, didn't get event within [60000 milliseconds], highest sequence number seen [0]
akka.persistence.typed.internal.JournalFailureException: Exception during recovery. Last known sequence number [0]. PersistenceId [first], due to: Replay timed out, didn't get event within [60000 milliseconds], highest sequence number seen [0]
    at akka.persistence.typed.internal.ReplayingEvents.onRecoveryFailure(ReplayingEvents.scala:263)
2020-11-20 12:21:55,999 WAR Persistence               No default snapshot store configured! To configure a default snapshot-store plugin set the `akka.persistence.snapshot-store.plugin` key. For details see 'reference.conf'
2020-11-20 12:21:56,070 WAR HikariConfig              slick.db - using dataSourceClassName and ignoring jdbcUrl.
2020-11-20 12:21:56,073 INF HikariDataSource          slick.db - Starting...
2020-11-20 12:21:56,109 INF HikariDataSource          slick.db - Start completed.

下面是我的application.conf

akka {
  loglevel = DEBUG

  persistence {
    journal.plugin = "jdbc-journal"
    snapshot-store.plugin = "jdbc-snapshot-store"
  }
}

jdbc-journal {
  slick = ${slick}
}

jdbc-snapshot-store {
  slick = ${slick}
}

jdbc-read-journal {
  slick = ${slick}
}


slick {
  profile = "slick.jdbc.MySQLProfile$"
  db {
    dataSourceClass = "slick.jdbc.DriverDataSource"
    driver = "com.mysql.cj.jdbc.Driver"
    url = "jdbc:mysql://localhost:3306/"
    user = nilu
    password = "password"
  }
}

共有1个答案

阚英武
2023-03-14

使用OnPersistFailure方法。如果持久化失败,则调用此方法。演员将会弯腰驼背。最佳实践是在一段时间后再次启动actor并使用Backoff supervisor。

并使用OnPersistRejected方法。如果日记未能持久化事件,则调用此方法。演员恢复演出。(参考资料)

class MyPersistentActor extends PersistentActor with ActorLogging {
    override def persistenceId: String = ???
    override def receiveCommand: Receive = ???
    override def receiveRecover: Receive = ???

    override def onPersistFailure(cause: Throwable, event: Any, seqNr: Long): Unit = {
      log.error(s"fail to persist $event because of: $cause")
      super.onPersistFailure(cause, event, seqNr)
    }

    override def onPersistRejected(cause: Throwable, event: Any, seqNr: Long): Unit = {
      log.error(s"persist rejected for $event because of: $cause")
      super.onPersistRejected(cause, event, seqNr)
    }
  }
 类似资料:
  • ConfigEmbeddedWebApplicationContext:上下文初始化过程中遇到异常-取消刷新att empt:org.springframework.beans.factory.beanCreationException:创建类路径资源[org/springframework/boot/autoconfiguration/orm/jpa/hibernatejpaAutoConfig

  • 我熟悉此处定义的Akka测试方法: http://doc.akka.io/docs/akka/snapshot/scala/testing.html 我了解如何使用TestKit、TestActorRef、TestProbe等。我还了解我的核心域逻辑应该与Akka隔离提取和测试。 我的问题是关于在Akka Persistence参与者(即PersistentActor和PersistentView

  • 从Akka中获取序列化错误,如下所示,如何包装Akka消息中的不可序列化成员/字段?异常确实命名了不能序列化的成员值(在),但该对象本身包含许多嵌套成员,并且错误消息似乎很少提供关于不能序列化的违规嵌套对象的线索: 2018-05-24T06:30:51.897Z错误VCA-Akka.actor.default-dispatcher-4Akka.remote.EndpointWriter-未能使用

  • 我正在寻找从经典Akka持久化迁移到Akka持久化类型。在这里找到的Lagom留档:1说“注意:从Lagom持久化(经典)迁移到Akka持久化类型时的唯一限制是需要完全关闭集群。即使所有持久数据都是兼容的,Lagom持久化(经典)和Akka持久化类型也不能共存。” 有人知道这是否适用于服务器可能知道的所有持久实体吗?例如,我使用的服务有3个独立的持久实体。我需要一次迁移所有3个,还是可以一次迁移一

  • 我目前正在开发一个企业应用程序,我在设置实体管理器工厂时遇到了问题。我一直收到这条信息。 我已经在上面好几天了!请帮助!!!这是我的persitence.xml

  • 我尝试了一个带有MongoDb支持的akka-persistence的“Hello-World”示例,使用这个开源https://github.com/scullxbones/akka-persistence-mongo/tree/master/rxmongo/src。下面是我的代码。但是,当我运行应用程序时,我得到了ask Timeout: Akka.Pattern.AskTimeoutExce