[英]Configure Transaction attempts in Spring JPA
我有一个使用JPA配置的Spring应用程序,我想配置死锁重试。 如何在application.properties
文件中配置它? 目前,我只有这种配置:
spring.datasource.jndi-name=java:/global/test
spring.datasource.driver-class-name=org.mariadb.jdbc.Driver
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MariaDBDialect
spring.jpa.show-sql = true
spring.jpa.hibernate.ddl-auto = update
根据Spring官方文档的附录A-Common application.properties部分,可以配置:
spring.jta.atomikos.properties.recovery.max = n
# ^-- retry count here, n >= 0, default = 5.
假设您在运行时在应用程序中将Atomikos用作JTA提供程序。 配置了Atomikos后,您至少可以重试失败的事务:
引发异常之前提交事务的重试尝试次数。
但是,这不能保证在执行1次或n次重试之前就可以解决死锁情况。
您可能还需要检查属性
spring.jta.atomikos.properties.recovery.retry-interval=10000ms
配置“重试尝试之间的延迟”。
希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.