Narayana Transaction

Import Maven Dependency

  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.apache.shardingsphere</groupId>
  8. <artifactId>shardingsphere-jdbc-core</artifactId>
  9. <version>${shardingsphere.version}</version>
  10. </dependency>
  11. <!-- Import if using XA transaction -->
  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>

Customize Configuration Items

Add jbossts-properties.xml in classpath of the application to customize Narayana configuration.

Please refer to Narayana official documentation for more details.

Configure XA Transaction Manager Type

Yaml:

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

SpringBoot:

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

Spring Namespace:

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