Narayana Transaction

Background

Apache ShardingSphere provides XA transactions that integrate with the Narayana implementation.

Prerequisites

Introducing Maven dependency

  1. <properties>
  2. <narayana.version>5.12.4.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.apache.shardingsphere</groupId>
  8. <artifactId>shardingsphere-jdbc-core</artifactId>
  9. <version>${shardingsphere.version}</version>
  10. </dependency>
  11. <!-- This module is required when using XA transactions -->
  12. <dependency>
  13. <groupId>org.apache.shardingsphere</groupId>
  14. <artifactId>shardingsphere-transaction-xa-core</artifactId>
  15. <version>${shardingsphere.version}</version>
  16. </dependency>
  17. <dependency>
  18. <groupId>org.apache.shardingsphere</groupId>
  19. <artifactId>shardingsphere-transaction-xa-narayana</artifactId>
  20. <version>${shardingsphere.version}</version>
  21. </dependency>
  22. <dependency>
  23. <groupId>org.jboss.narayana.jta</groupId>
  24. <artifactId>jta</artifactId>
  25. <version>${narayana.version}</version>
  26. </dependency>
  27. <dependency>
  28. <groupId>org.jboss.narayana.jts</groupId>
  29. <artifactId>narayana-jts-integration</artifactId>
  30. <version>${narayana.version}</version>
  31. </dependency>
  32. <dependency>
  33. <groupId>org.jboss</groupId>
  34. <artifactId>jboss-transaction-spi</artifactId>
  35. <version>${jboss-transaction-spi.version}</version>
  36. </dependency>
  37. <dependency>
  38. <groupId>org.jboss.logging</groupId>
  39. <artifactId>jboss-logging</artifactId>
  40. <version>${jboss-logging.version}</version>
  41. </dependency>

Procedure

  1. Configure Narayana
  2. Set the XA transaction type

Sample

Configure Narayana

Narayana configuration items can be customized by adding jbossts-properties.xml to the project’s classpath.

See Narayana’s Official Documentation for more details.

Set the XA transaction type

Yaml:

  1. transaction:
  2. defaultType: XA
  3. providerType: Narayana