Bitronix 事务

引入 Maven 依赖

  1. <properties>
  2. <btm.version>2.1.3</btm.version>
  3. </properties>
  4. <dependency>
  5. <groupId>org.apache.shardingsphere</groupId>
  6. <artifactId>shardingsphere-jdbc-core</artifactId>
  7. <version>${shardingsphere.version}</version>
  8. </dependency>
  9. <!-- 使用 XA 事务时,需要引入此模块 -->
  10. <dependency>
  11. <groupId>org.apache.shardingsphere</groupId>
  12. <artifactId>shardingsphere-transaction-xa-core</artifactId>
  13. <version>${shardingsphere.version}</version>
  14. </dependency>
  15. <dependency>
  16. <groupId>org.apache.shardingsphere</groupId>
  17. <artifactId>shardingsphere-transaction-xa-bitronix</artifactId>
  18. <version>${shardingsphere.version}</version>
  19. </dependency>
  20. <dependency>
  21. <groupId>org.codehaus.btm</groupId>
  22. <artifactId>btm</artifactId>
  23. <version>${btm.version}</version>
  24. </dependency>

定制化配置项

详情请参见 Bitronix 官方文档

设置 XA 事务管理类型

Yaml:

  1. - !TRANSACTION
  2. defaultType: XA
  3. providerType: Bitronix

SpringBoot:

  1. spring:
  2. shardingsphere:
  3. props:
  4. xa-transaction-manager-type: Bitronix

Spring Namespace:

  1. <shardingsphere:data-source id="xxx" data-source-names="xxx" rule-refs="xxx">
  2. <props>
  3. <prop key="xa-transaction-manager-type">Bitronix</prop>
  4. </props>
  5. </shardingsphere:data-source>