SpringBoot 分布式事務框架Atomioks


 新版分布式事務框框有阿里的Seata,可前往自行研究,我暫時沒有使用過:https://github.com/seata/seatahttps://gitee.com/seata-io/seata

1.pom依賴

<dependency>
  <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-jta-atomikos</artifactId>
</dependency>

2.application.properties配置文件

3. Atomikos的原理

    A. 每個數據源執行時獲取一個標記事務的唯一ID;

  B. 每個數據源做execute;

  C. 每個數據源做end,標記這個數據庫的sql已經執行完畢,不會再執行別的語句,該事務已經可以提交了;

  D. 每個數據源做prepare,預提交該事務;

  E. 如果所有的prepare都是成功的,則commit,否則rollback。

10.JTA分布式事務執行報org.springframework.transaction.UnexpectedRollbackException: JTA transaction unexpectedly rolled back (maybe due to a timeout); nested exception is javax.transaction.RollbackException: Prepare: NO vote    atomikos版本3.9.3

  解決方式:在application.properties文件中

# 默認的超時時間單位毫秒
spring.jta.atomikos.properties.default-jta-timeout=30000000
spring.jta.atomikos.properties.max-timeout=3000000
#配置最大的事務活動個數,-1代表無限制(atomikos版本3.9.3)
spring.jta.atomikos.properties.max-actives=-1

 

可參考:https://blog.csdn.net/u011042955/article/details/86998664

 

 

可參考:http://blog.jobbole.com/95632/

    https://sylvanassun.github.io/2016/08/01/2016-08-1-Spring-data-transaction/

    https://blog.csdn.net/cckevincyh/article/details/79189888

    https://blog.csdn.net/catoop/article/details/50595702

    http://www.cnblogs.com/zengkefu/p/5742617.html


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM