Distributed Transaction

ShardingSphere-Proxy supports LOCAL, XA, BASE transactions, LOCAL transaction is default value, it is original transaction of relational database.

XA transaction

Default XA transaction manager of ShardingSphere is Atomikos. Users can customize Atomikos configuration items through adding jta.properties in conf catalog of ShardingSphere-Proxy. Please refer to Official Documents of Atomikos for detailed configurations.

  • Use Narayana XA Transaction Manager。
  1. Copy the jar file required by Narayana to conf/lib. The reference package is as follows:
  1. <properties>
  2. <narayana.version>5.9.1.Final</narayana.version>
  3. <jboss-transaction-spi.version>7.6.0.Final</jboss-transaction-spi.version>
  4. <jboss-logging.version>3.2.1.Final</jboss-logging.version>
  5. </properties>
  6. <dependency>
  7. <groupId>org.jboss.narayana.jta</groupId>
  8. <artifactId>jta</artifactId>
  9. <version>${narayana.version}</version>
  10. </dependency>
  11. <dependency>
  12. <groupId>org.jboss.narayana.jts</groupId>
  13. <artifactId>narayana-jts-integration</artifactId>
  14. <version>${narayana.version}</version>
  15. </dependency>
  16. <dependency>
  17. <groupId>org.jboss</groupId>
  18. <artifactId>jboss-transaction-spi</artifactId>
  19. <version>${jboss-transaction-spi.version}</version>
  20. </dependency>
  21. <dependency>
  22. <groupId>org.jboss.logging</groupId>
  23. <artifactId>jboss-logging</artifactId>
  24. <version>${jboss-logging.version}</version>
  25. </dependency>
  1. Configure xa-transaction-manager-type in conf/server.yaml
  1. - !TRANSACTION
  2. defaultType: XA
  3. providerType: Narayana
  1. Add jbossts-properties.xml to customize Narayana configuration. The order of path loading is user.dir (pwd) > user.home > java.home > classpath. Please refer to Narayana official documentation for more details.
  • Use Bitronix XA Transaction Manager。
  1. Copy the jar file required by Bitronix to conf/lib. The reference package is as follows:
  1. <properties>
  2. <btm.version>2.1.3</btm.version>
  3. </properties>
  4. <dependency>
  5. <groupId>org.apache.shardingsphere</groupId>
  6. <artifactId>shardingsphere-transaction-xa-bitronix</artifactId>
  7. <version>${shardingsphere.version}</version>
  8. </dependency>
  9. <dependency>
  10. <groupId>org.codehaus.btm</groupId>
  11. <artifactId>btm</artifactId>
  12. <version>${btm.version}</version>
  13. </dependency>
  1. Configure xa-transaction-manager-type in conf/server.yaml
  1. - !TRANSACTION
  2. defaultType: XA
  3. providerType: Bitronix
  1. Please refer to Bitronix official documentation for more details.

BASE Transaction

Since we have not packed the BASE implementation jar into ShardingSphere-Proxy, you should copy relevant jar which implement ShardingSphereTransactionManager SPI to conf/lib, then switch the transaction type to BASE.