This is an automated email from the ASF dual-hosted git repository.
menghaoran pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 086e22d421d update special-api doc for transaction (#19073)
086e22d421d is described below
commit 086e22d421dec07985f6e16d5eb1679757f016cd
Author: JingShang Lu <[email protected]>
AuthorDate: Wed Jul 13 08:04:38 2022 +0800
update special-api doc for transaction (#19073)
---
.../special-api/transaction/atomikos.cn.md | 46 ++++++++++++++++--
.../special-api/transaction/atomikos.en.md | 50 +++++++++++++++++---
.../special-api/transaction/bitronix.cn.md | 21 +++++++--
.../special-api/transaction/bitronix.en.md | 23 +++++++--
.../special-api/transaction/java-api.cn.md | 39 +++++++++++----
.../special-api/transaction/java-api.en.md | 45 +++++++++++++-----
.../special-api/transaction/narayana.cn.md | 22 +++++++--
.../special-api/transaction/narayana.en.md | 55 +++++++++++++---------
.../special-api/transaction/seata.cn.md | 18 +++++--
.../special-api/transaction/seata.en.md | 30 ++++++++----
.../transaction/spring-boot-starter.cn.md | 31 +++++++++---
.../transaction/spring-boot-starter.en.md | 37 +++++++++++----
.../special-api/transaction/spring-namespace.cn.md | 31 +++++++++---
.../special-api/transaction/spring-namespace.en.md | 42 ++++++++++++-----
14 files changed, 375 insertions(+), 115 deletions(-)
diff --git
a/docs/document/content/user-manual/shardingsphere-jdbc/special-api/transaction/atomikos.cn.md
b/docs/document/content/user-manual/shardingsphere-jdbc/special-api/transaction/atomikos.cn.md
index 84539d8641d..7e7a21f9d76 100644
---
a/docs/document/content/user-manual/shardingsphere-jdbc/special-api/transaction/atomikos.cn.md
+++
b/docs/document/content/user-manual/shardingsphere-jdbc/special-api/transaction/atomikos.cn.md
@@ -3,14 +3,50 @@ title = "Atomikos 事务"
weight = 4
+++
-Apache ShardingSphere 默认的 XA 事务管理器为 Atomikos。
+## 背景信息
-## 数据恢复
+Apache ShardingSphere 提供 XA 事务,默认的 XA 事务实现为 Atomikos。
+## 操作步骤
-在项目的 `logs` 目录中会生成 `xa_tx.log`, 这是 XA 崩溃恢复时所需的日志,请勿删除。
+1. 配置事务类型
+2. 配置 Atomikos
+
+## 配置示例
+
+### 配置事务类型
+
+Yaml:
+
+```yaml
+- !TRANSACTION
+ defaultType: XA
+ providerType: Atomikos
+```
+
+SpringBoot:
-## 修改配置
+```yaml
+spring:
+ shardingsphere:
+ props:
+ xa-transaction-manager-type: Atomikos
+```
+
+Spring Namespace:
+
+```xml
+<shardingsphere:data-source id="xxx" data-source-names="xxx" rule-refs="xxx">
+ <props>
+ <prop key="xa-transaction-manager-type">Atomikos</prop>
+ </props>
+</shardingsphere:data-source>
+```
+### 配置 Atomikos
可以通过在项目的 classpath 中添加 `jta.properties` 来定制化 Atomikos 配置项。
-详情请参见 [Atomikos 官方文档](https://www.atomikos.com/Documentation/JtaProperties)。
+详情请参见 [Atomikos 官方文档](https://www.atomikos.com/Documentation/JtaProperties) 。
+
+### 数据恢复
+
+在项目的 `logs` 目录中会生成 `xa_tx.log`, 这是 XA 崩溃恢复时所需的日志,请勿删除。
diff --git
a/docs/document/content/user-manual/shardingsphere-jdbc/special-api/transaction/atomikos.en.md
b/docs/document/content/user-manual/shardingsphere-jdbc/special-api/transaction/atomikos.en.md
index 685191aa336..73fe9278b9b 100644
---
a/docs/document/content/user-manual/shardingsphere-jdbc/special-api/transaction/atomikos.en.md
+++
b/docs/document/content/user-manual/shardingsphere-jdbc/special-api/transaction/atomikos.en.md
@@ -3,15 +3,51 @@ title = "Atomikos Transaction"
weight = 4
+++
-The default XA transaction manager of Apache ShardingSphere is Atomikos.
+## Background
-## Data Recovery
+Apache ShardingSphere provides XA transactions, and the default XA transaction
manager is Atomikos.
-`xa_tx.log` generated in the project `logs` folder is necessary for the
recovery when XA crashes. Please keep it.
+## Procedure
-## Update Configuration
+1. Configure the transaction type
+2. Configure Atomikos
-Developer can add `jta.properties` in classpath of the application to
customize Atomikos configuration.
-For detailed configuration rules.
+## Sample
-Please refer to [Atomikos official
documentation](https://www.atomikos.com/Documentation/JtaProperties) for more
details.
+### Configure the transaction type
+
+Yaml:
+
+```yaml
+- !TRANSACTION
+ defaultType: XA
+ providerType: Atomikos
+```
+
+SpringBoot:
+
+```yaml
+spring:
+ shardingsphere:
+ props:
+ xa-transaction-manager-type: Atomikos
+```
+
+Spring Namespace:
+
+```xml
+<shardingsphere:data-source id="xxx" data-source-names="xxx" rule-refs="xxx">
+ <props>
+ <prop key="xa-transaction-manager-type">Atomikos</prop>
+ </props>
+</shardingsphere:data-source>
+```
+### Configure Atomikos
+
+Atomikos configuration items can be customized by adding `jta.properties` to
the project's classpath.
+
+See [Atomikos's official
documentation](https://www.atomikos.com/Documentation/JtaProperties) for more
details.
+
+### Data Recovery
+
+`xa_tx.log` is generated in the `logs` directory of the project. This is the
log required for recovering XA crash. Do not delete it.
diff --git
a/docs/document/content/user-manual/shardingsphere-jdbc/special-api/transaction/bitronix.cn.md
b/docs/document/content/user-manual/shardingsphere-jdbc/special-api/transaction/bitronix.cn.md
index be00505b0b0..b914a101629 100644
---
a/docs/document/content/user-manual/shardingsphere-jdbc/special-api/transaction/bitronix.cn.md
+++
b/docs/document/content/user-manual/shardingsphere-jdbc/special-api/transaction/bitronix.cn.md
@@ -3,7 +3,13 @@ title = "Bitronix 事务"
weight = 6
+++
-## 引入 Maven 依赖
+## 背景信息
+
+Apache ShardingSphere 提供 XA 事务,集成了 Bitronix 的实现。
+
+## 前提条件
+
+引入 Maven 依赖
```xml
<properties>
@@ -36,11 +42,14 @@ weight = 6
</dependency>
```
-## 定制化配置项
+## 操作步骤
-详情请参见 [Bitronix 官方文档](https://github.com/bitronix/btm/wiki)。
+1. 配置 XA 事务类型
+2. 配置 Bitronix
-## 设置 XA 事务管理类型
+## 配置示例
+
+### 配置 XA 事务类型
Yaml:
@@ -68,3 +77,7 @@ Spring Namespace:
</props>
</shardingsphere:data-source>
```
+
+### 配置 Bitronix (可省略)
+
+详情请参见 [Bitronix 官方文档](https://github.com/bitronix/btm/wiki) 。
diff --git
a/docs/document/content/user-manual/shardingsphere-jdbc/special-api/transaction/bitronix.en.md
b/docs/document/content/user-manual/shardingsphere-jdbc/special-api/transaction/bitronix.en.md
index 56c29fb4f99..0265cae19b0 100644
---
a/docs/document/content/user-manual/shardingsphere-jdbc/special-api/transaction/bitronix.en.md
+++
b/docs/document/content/user-manual/shardingsphere-jdbc/special-api/transaction/bitronix.en.md
@@ -3,7 +3,13 @@ title = "Bitronix Transaction"
weight = 5
+++
-## Import Maven Dependency
+## background
+
+Apache ShardingSphere provides XA transactions that integrate with the
Bitronix implementation.
+
+## Prerequisites
+
+Introducing Maven dependency
```xml
<properties>
@@ -16,12 +22,13 @@ weight = 5
<version>${shardingsphere.version}</version>
</dependency>
+<!-- This module is required when using XA transactions -->
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-transaction-xa-core</artifactId>
<version>${shardingsphere.version}</version>
</dependency>
-
+
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-transaction-xa-bitronix</artifactId>
@@ -35,11 +42,14 @@ weight = 5
</dependency>
```
-## Customize Configuration Items
+## Procedure
+
+1. Configure the XA transaction type
+2. Configure Bitronix
-Please refer to [Bitronix official
documentation](https://github.com/bitronix/btm/wiki) for more details.
+## Sample
-## Configure XA Transaction Manager Type
+### Configure the XA transaction type
Yaml:
@@ -67,3 +77,6 @@ Spring Namespace:
</props>
</shardingsphere:data-source>
```
+
+### Configure Bitronix (Deletable)
+See [Bitronix's Official Documentation](https://github.com/bitronix/btm/wiki)
for more details.
diff --git
a/docs/document/content/user-manual/shardingsphere-jdbc/special-api/transaction/java-api.cn.md
b/docs/document/content/user-manual/shardingsphere-jdbc/special-api/transaction/java-api.cn.md
index 7248825a71a..e818b6b590e 100644
---
a/docs/document/content/user-manual/shardingsphere-jdbc/special-api/transaction/java-api.cn.md
+++
b/docs/document/content/user-manual/shardingsphere-jdbc/special-api/transaction/java-api.cn.md
@@ -3,7 +3,13 @@ title = "使用 Java API"
weight = 1
+++
-## 引入 Maven 依赖
+## 背景信息
+
+使用 ShardingSphere-JDBC 时,可以通过 API 的方式使用 XA 和 BASE 模式的事务。
+
+## 前提条件
+
+引入 Maven 依赖
```xml
<dependency>
@@ -19,6 +25,13 @@ weight = 1
<version>${shardingsphere.version}</version>
</dependency>
+<!-- 使用 XA 的 Narayana模式时,需要引入此模块 -->
+<dependency>
+ <groupId>org.apache.shardingsphere</groupId>
+ <artifactId>shardingsphere-transaction-xa-narayana</artifactId>
+ <version>${project.version}</version>
+</dependency>
+
<!-- 使用 BASE 事务时,需要引入此模块 -->
<dependency>
<groupId>org.apache.shardingsphere</groupId>
@@ -27,16 +40,22 @@ weight = 1
</dependency>
```
-## 使用分布式事务
+
+## 操作步骤
+
+1. 设置事务类型
+2. 执行业务逻辑
+
+## 配置示例
```java
TransactionTypeHolder.set(TransactionType.XA); // 支持 TransactionType.LOCAL,
TransactionType.XA, TransactionType.BASE
-try (Connection conn = dataSource.getConnection()) { // 使用
ShardingSphereDataSource
- conn.setAutoCommit(false);
- PreparedStatement ps = conn.prepareStatement("INSERT INTO t_order
(user_id, status) VALUES (?, ?)");
- ps.setObject(1, 1000);
- ps.setObject(2, "init");
- ps.executeUpdate();
- conn.commit();
-}
+ try (Connection conn = dataSource.getConnection()) { // 使用
ShardingSphereDataSource
+ conn.setAutoCommit(false);
+ PreparedStatement ps = conn.prepareStatement("INSERT INTO t_order
(user_id, status) VALUES (?, ?)");
+ ps.setObject(1, 1000);
+ ps.setObject(2, "init");
+ ps.executeUpdate();
+ conn.commit();
+ }
```
diff --git
a/docs/document/content/user-manual/shardingsphere-jdbc/special-api/transaction/java-api.en.md
b/docs/document/content/user-manual/shardingsphere-jdbc/special-api/transaction/java-api.en.md
index 900aa47b703..d1ea538575c 100644
---
a/docs/document/content/user-manual/shardingsphere-jdbc/special-api/transaction/java-api.en.md
+++
b/docs/document/content/user-manual/shardingsphere-jdbc/special-api/transaction/java-api.en.md
@@ -3,7 +3,13 @@ title = "Use Java API"
weight = 1
+++
-## Import Maven Dependency
+## Background
+
+With ShardingSphere-JDBC, XA and BASE mode transactions can be used through
the API.
+
+## Prerequisites
+
+Introducing Maven dependency
```xml
<dependency>
@@ -12,14 +18,21 @@ weight = 1
<version>${shardingsphere.version}</version>
</dependency>
-<!-- import if using XA transaction -->
+<!-- This module is required when using XA transactions -->
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-transaction-xa-core</artifactId>
<version>${shardingsphere.version}</version>
</dependency>
-<!-- import if using BASE transaction -->
+<!-- This module is required when using XA's Narayana mode -->
+<dependency>
+ <groupId>org.apache.shardingsphere</groupId>
+ <artifactId>shardingsphere-transaction-xa-narayana</artifactId>
+ <version>${project.version}</version>
+</dependency>
+
+<!-- This module is required when using BASE transactions -->
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-transaction-base-seata-at</artifactId>
@@ -27,16 +40,22 @@ weight = 1
</dependency>
```
-## Use Distributed Transaction
+
+## Procedure
+
+1. Set the transaction type
+2. Perform the business logic
+
+## Sample
```java
-TransactionTypeHolder.set(TransactionType.XA); // Support
TransactionType.LOCAL, TransactionType.XA, TransactionType.BASE
-try (Connection conn = dataSource.getConnection()) { // Use
ShardingSphereDataSource
- conn.setAutoCommit(false);
- PreparedStatement ps = conn.prepareStatement("INSERT INTO t_order
(user_id, status) VALUES (?, ?)");
- ps.setObject(1, 1000);
- ps.setObject(2, "init");
- ps.executeUpdate();
- conn.commit();
-}
+TransactionTypeHolder.set(TransactionType.XA); // support
TransactionType.LOCAL, TransactionType.XA, TransactionType.BASE
+ try (Connection conn = dataSource.getConnection()) { // use
ShardingSphereDataSource
+ conn.setAutoCommit(false);
+ PreparedStatement ps = conn.prepareStatement("INSERT INTO t_order
(user_id, status) VALUES (?, ?)");
+ ps.setObject(1, 1000);
+ ps.setObject(2, "init");
+ ps.executeUpdate();
+ conn.commit();
+ }
```
diff --git
a/docs/document/content/user-manual/shardingsphere-jdbc/special-api/transaction/narayana.cn.md
b/docs/document/content/user-manual/shardingsphere-jdbc/special-api/transaction/narayana.cn.md
index 04b8c0dfa45..b610008e2f3 100644
---
a/docs/document/content/user-manual/shardingsphere-jdbc/special-api/transaction/narayana.cn.md
+++
b/docs/document/content/user-manual/shardingsphere-jdbc/special-api/transaction/narayana.cn.md
@@ -3,11 +3,17 @@ title = "Narayana 事务"
weight = 5
+++
-## 引入 Maven 依赖
+## 背景信息
+
+Apache ShardingSphere 提供 XA 事务,集成了 Narayana 的实现。
+
+## 前提条件
+
+引入 Maven 依赖
```xml
<properties>
- <narayana.version>5.9.1.Final</narayana.version>
+ <narayana.version>5.12.4.Final</narayana.version>
<jboss-transaction-spi.version>7.6.0.Final</jboss-transaction-spi.version>
<jboss-logging.version>3.2.1.Final</jboss-logging.version>
</properties>
@@ -51,14 +57,20 @@ weight = 5
<version>${jboss-logging.version}</version>
</dependency>
```
+## 操作步骤
+
+1. 配置 Narayana
+2. 设置 XA 事务类型
+
+## 配置示例
-## 定制化配置项
+### 配置 Narayana
可以通过在项目的 classpath 中添加 `jbossts-properties.xml` 来定制化 Narayana 配置项。
-详情请参见 [Narayana 官方文档](https://narayana.io/documentation/index.html)。
+详情请参见 [Narayana 官方文档](https://narayana.io/documentation/index.html) 。
-## 设置 XA 事务管理类型
+### 设置 XA 事务类型
Yaml:
diff --git
a/docs/document/content/user-manual/shardingsphere-jdbc/special-api/transaction/narayana.en.md
b/docs/document/content/user-manual/shardingsphere-jdbc/special-api/transaction/narayana.en.md
index c7d4a4cbb00..320c9440f19 100644
---
a/docs/document/content/user-manual/shardingsphere-jdbc/special-api/transaction/narayana.en.md
+++
b/docs/document/content/user-manual/shardingsphere-jdbc/special-api/transaction/narayana.en.md
@@ -3,11 +3,17 @@ title = "Narayana Transaction"
weight = 5
+++
-## Import Maven Dependency
+## Background
+
+Apache ShardingSphere provides XA transactions that integrate with the
Narayana implementation.
+
+## Prerequisites
+
+Introducing Maven dependency
```xml
<properties>
- <narayana.version>5.9.1.Final</narayana.version>
+ <narayana.version>5.12.4.Final</narayana.version>
<jboss-transaction-spi.version>7.6.0.Final</jboss-transaction-spi.version>
<jboss-logging.version>3.2.1.Final</jboss-logging.version>
</properties>
@@ -18,7 +24,7 @@ weight = 5
<version>${shardingsphere.version}</version>
</dependency>
-<!-- Import if using XA transaction -->
+<!-- This module is required when using XA transactions -->
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-transaction-xa-core</artifactId>
@@ -26,39 +32,44 @@ weight = 5
</dependency>
<dependency>
- <groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-transaction-xa-narayana</artifactId>
- <version>${shardingsphere.version}</version>
+ <groupId>org.apache.shardingsphere</groupId>
+ <artifactId>shardingsphere-transaction-xa-narayana</artifactId>
+ <version>${shardingsphere.version}</version>
</dependency>
<dependency>
- <groupId>org.jboss.narayana.jta</groupId>
- <artifactId>jta</artifactId>
- <version>${narayana.version}</version>
+ <groupId>org.jboss.narayana.jta</groupId>
+ <artifactId>jta</artifactId>
+ <version>${narayana.version}</version>
</dependency>
<dependency>
- <groupId>org.jboss.narayana.jts</groupId>
- <artifactId>narayana-jts-integration</artifactId>
- <version>${narayana.version}</version>
+ <groupId>org.jboss.narayana.jts</groupId>
+ <artifactId>narayana-jts-integration</artifactId>
+ <version>${narayana.version}</version>
</dependency>
<dependency>
- <groupId>org.jboss</groupId>
- <artifactId>jboss-transaction-spi</artifactId>
- <version>${jboss-transaction-spi.version}</version>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-transaction-spi</artifactId>
+ <version>${jboss-transaction-spi.version}</version>
</dependency>
<dependency>
- <groupId>org.jboss.logging</groupId>
- <artifactId>jboss-logging</artifactId>
- <version>${jboss-logging.version}</version>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging</artifactId>
+ <version>${jboss-logging.version}</version>
</dependency>
```
+## Procedure
+1. Configure Narayana
+2. Set the XA transaction type
+
+## Sample
-## Customize Configuration Items
+### Configure Narayana
-Add `jbossts-properties.xml` in classpath of the application to customize
Narayana configuration.
+Narayana configuration items can be customized by adding
`jbossts-properties.xml` to the project's classpath.
-Please refer to [Narayana official
documentation](https://narayana.io/documentation/index.html) for more details.
+See [Narayana's Official
Documentation](https://narayana.io/documentation/index.html) for more details.
-## Configure XA Transaction Manager Type
+### Set the XA transaction type
Yaml:
diff --git
a/docs/document/content/user-manual/shardingsphere-jdbc/special-api/transaction/seata.cn.md
b/docs/document/content/user-manual/shardingsphere-jdbc/special-api/transaction/seata.cn.md
index ea764a03f28..7a41e181ca9 100644
---
a/docs/document/content/user-manual/shardingsphere-jdbc/special-api/transaction/seata.cn.md
+++
b/docs/document/content/user-manual/shardingsphere-jdbc/special-api/transaction/seata.cn.md
@@ -3,11 +3,23 @@ title = "Seata 事务"
weight = 7
+++
-## 启动 Seata 服务
+## 背景信息
+
+Apache ShardingSphere 提供 BASE 事务,集成了 Seata 的实现。
+
+## 操作步骤
+
+1. 启动 Seata Server
+2. 创建日志表
+3. 添加 Seata 配置
+
+## 配置示例
+
+### 启动 Seata Server
按照 [seata-work-shop](https://github.com/seata/seata-workshop) 中的步骤,下载并启动 Seata
服务器。
-## 创建日志表
+### 创建 undo_log 表
在每一个分片数据库实例中执创建 `undo_log` 表(以 MySQL 为例)。
@@ -29,7 +41,7 @@ CREATE TABLE IF NOT EXISTS `undo_log`
DEFAULT CHARSET = utf8 COMMENT ='AT transaction mode undo table';
```
-## 修改配置
+### 修改配置
在 classpath 中增加 `seata.conf` 文件。
diff --git
a/docs/document/content/user-manual/shardingsphere-jdbc/special-api/transaction/seata.en.md
b/docs/document/content/user-manual/shardingsphere-jdbc/special-api/transaction/seata.en.md
index ccd46f3bb93..92d72d30266 100644
---
a/docs/document/content/user-manual/shardingsphere-jdbc/special-api/transaction/seata.en.md
+++
b/docs/document/content/user-manual/shardingsphere-jdbc/special-api/transaction/seata.en.md
@@ -3,13 +3,25 @@ title = "Seata Transaction"
weight = 7
+++
-## Startup Seata Server
+## Background
-Download seata server according to
[seata-work-shop](https://github.com/seata/seata-workshop).
+Apache ShardingSphere provides BASE transactions that integrate the Seata
implementation.
-## Create Undo Log Table
+## Procedure
-Create `undo_log` table in each physical database (sample for MySQL).
+1. Start Seata Server
+2. Create the log table
+3. Add the Seata configuration
+
+## Sample
+
+### Start Seata Server
+
+Refer to [seata-work-shop](https://github.com/seata/seata-workshop) to
download and start the Seata server.
+
+### Create undo_log table
+
+Create the `undo_log` table in each shard database instance (take MySQL as an
example).
```sql
CREATE TABLE IF NOT EXISTS `undo_log`
@@ -29,15 +41,15 @@ CREATE TABLE IF NOT EXISTS `undo_log`
DEFAULT CHARSET = utf8 COMMENT ='AT transaction mode undo table';
```
-## Update Configuration
+### Modify configuration
-Configure `seata.conf` file in classpath.
+Add the `seata.conf` file to the classpath.
```conf
client {
- application.id = example ## application unique ID
- transaction.service.group = my_test_tx_group ## transaction group
+ application.id = example ## Apply the only primary key
+ transaction.service.group = my_test_tx_group ## The transaction group it
belongs to.
}
```
-Modify `file.conf` and `registry.conf` if needed.
+Modify the `file.conf` and `registry.conf` files of Seata as required.
diff --git
a/docs/document/content/user-manual/shardingsphere-jdbc/special-api/transaction/spring-boot-starter.cn.md
b/docs/document/content/user-manual/shardingsphere-jdbc/special-api/transaction/spring-boot-starter.cn.md
index 3f487090dcd..3350a937604 100644
---
a/docs/document/content/user-manual/shardingsphere-jdbc/special-api/transaction/spring-boot-starter.cn.md
+++
b/docs/document/content/user-manual/shardingsphere-jdbc/special-api/transaction/spring-boot-starter.cn.md
@@ -3,7 +3,12 @@ title = "使用 Spring Boot Starter"
weight = 2
+++
-## 引入 Maven 依赖
+## 背景信息
+
+使用 ShardingSphere-JDBC 时,可以通过 spring boot starter 的方式使用。
+## 前提条件
+
+引入 Maven 依赖
```xml
<dependency>
@@ -19,6 +24,13 @@ weight = 2
<version>${shardingsphere.version}</version>
</dependency>
+<!-- 使用 XA 的 Narayana模式时,需要引入此模块 -->
+<dependency>
+ <groupId>org.apache.shardingsphere</groupId>
+ <artifactId>shardingsphere-transaction-xa-narayana</artifactId>
+ <version>${project.version}</version>
+</dependency>
+
<!-- 使用 BASE 事务时,需要引入此模块 -->
<dependency>
<groupId>org.apache.shardingsphere</groupId>
@@ -27,7 +39,14 @@ weight = 2
</dependency>
```
-## 配置事务管理器
+## 操作步骤
+
+1. 配置事务类型
+2. 使用分布式事务
+
+## 配置示例
+
+### 配置事务类型
```java
@Configuration
@@ -46,16 +65,16 @@ public class TransactionConfiguration {
}
```
-## 使用分布式事务
+### 使用分布式事务
```java
@Transactional
@ShardingSphereTransactionType(TransactionType.XA) //
支持TransactionType.LOCAL, TransactionType.XA, TransactionType.BASE
public void insert() {
- jdbcTemplate.execute("INSERT INTO t_order (user_id, status) VALUES (?,
?)", (PreparedStatementCallback<Object>) ps -> {
+ jdbcTemplate.execute("INSERT INTO t_order (user_id, status) VALUES (?,
?)", (PreparedStatementCallback<Object>) ps -> {
ps.setObject(1, i);
ps.setObject(2, "init");
ps.executeUpdate();
- });
-}
+ });
+ }
```
diff --git
a/docs/document/content/user-manual/shardingsphere-jdbc/special-api/transaction/spring-boot-starter.en.md
b/docs/document/content/user-manual/shardingsphere-jdbc/special-api/transaction/spring-boot-starter.en.md
index 64d24d5129a..6b24021da3d 100644
---
a/docs/document/content/user-manual/shardingsphere-jdbc/special-api/transaction/spring-boot-starter.en.md
+++
b/docs/document/content/user-manual/shardingsphere-jdbc/special-api/transaction/spring-boot-starter.en.md
@@ -3,7 +3,12 @@ title = "Use Spring Boot Starter"
weight = 2
+++
-## Import Maven Dependency
+## Background
+
+ShardingSphere-JDBC can be used through spring boot starter.
+## Prerequisites
+
+Introducing Maven dependency
```xml
<dependency>
@@ -12,14 +17,21 @@ weight = 2
<version>${shardingsphere.version}</version>
</dependency>
-<!-- import if using XA transaction -->
+<!-- This module is required when using XA transactions -->
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-transaction-xa-core</artifactId>
<version>${shardingsphere.version}</version>
</dependency>
-<!-- import if using BASE transaction -->
+<!-- This module is required when using XA's Narayana mode -->
+<dependency>
+ <groupId>org.apache.shardingsphere</groupId>
+ <artifactId>shardingsphere-transaction-xa-narayana</artifactId>
+ <version>${project.version}</version>
+</dependency>
+
+<!-- This module is required when using BASE transactions -->
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-transaction-base-seata-at</artifactId>
@@ -27,7 +39,14 @@ weight = 2
</dependency>
```
-## Configure Transaction Manager
+## Procedure
+
+1. Configure the transaction Type
+2. Use distributed transactions
+
+## Sample
+
+### Configure the transaction Type
```java
@Configuration
@@ -46,16 +65,16 @@ public class TransactionConfiguration {
}
```
-## Use Distributed Transaction
+### Use distributed transactions
```java
@Transactional
-@ShardingSphereTransactionType(TransactionType.XA) // Support
TransactionType.LOCAL, TransactionType.XA, TransactionType.BASE
+@ShardingSphereTransactionType(TransactionType.XA) //
支持TransactionType.LOCAL, TransactionType.XA, TransactionType.BASE
public void insert() {
- jdbcTemplate.execute("INSERT INTO t_order (user_id, status) VALUES (?,
?)", (PreparedStatementCallback<Object>) ps -> {
+ jdbcTemplate.execute("INSERT INTO t_order (user_id, status) VALUES (?,
?)", (PreparedStatementCallback<Object>) ps -> {
ps.setObject(1, i);
ps.setObject(2, "init");
ps.executeUpdate();
- });
-}
+ });
+ }
```
diff --git
a/docs/document/content/user-manual/shardingsphere-jdbc/special-api/transaction/spring-namespace.cn.md
b/docs/document/content/user-manual/shardingsphere-jdbc/special-api/transaction/spring-namespace.cn.md
index 6822b206eec..3e2615b8f89 100644
---
a/docs/document/content/user-manual/shardingsphere-jdbc/special-api/transaction/spring-namespace.cn.md
+++
b/docs/document/content/user-manual/shardingsphere-jdbc/special-api/transaction/spring-namespace.cn.md
@@ -3,7 +3,12 @@ title = "使用 Spring 命名空间"
weight = 3
+++
-## 引入 Maven 依赖
+## 背景信息
+
+使用 ShardingSphere-JDBC 时,可以通过 spring namespace 的方式使用。
+## 前提条件
+
+引入 Maven 依赖
```xml
<dependency>
@@ -19,6 +24,13 @@ weight = 3
<version>${shardingsphere.version}</version>
</dependency>
+<!-- 使用 XA 的 Narayana模式时,需要引入此模块 -->
+<dependency>
+ <groupId>org.apache.shardingsphere</groupId>
+ <artifactId>shardingsphere-transaction-xa-narayana</artifactId>
+ <version>${project.version}</version>
+</dependency>
+
<!-- 使用 BASE 事务时,需要引入此模块 -->
<dependency>
<groupId>org.apache.shardingsphere</groupId>
@@ -27,7 +39,14 @@ weight = 3
</dependency>
```
-## 配置事务管理器
+## 操作步骤
+
+1. 配置事务管理器
+2. 使用分布式事务
+
+## 配置示例
+
+### 配置事务管理器
```xml
<!-- ShardingDataSource 的相关配置 -->
@@ -45,16 +64,16 @@ weight = 3
<sharding:tx-type-annotation-driven />
```
-## 使用分布式事务
+### 使用分布式事务
```java
@Transactional
@ShardingSphereTransactionType(TransactionType.XA) //
支持TransactionType.LOCAL, TransactionType.XA, TransactionType.BASE
public void insert() {
- jdbcTemplate.execute("INSERT INTO t_order (user_id, status) VALUES (?,
?)", (PreparedStatementCallback<Object>) ps -> {
+ jdbcTemplate.execute("INSERT INTO t_order (user_id, status) VALUES (?,
?)", (PreparedStatementCallback<Object>) ps -> {
ps.setObject(1, i);
ps.setObject(2, "init");
ps.executeUpdate();
- });
-}
+ });
+ }
```
diff --git
a/docs/document/content/user-manual/shardingsphere-jdbc/special-api/transaction/spring-namespace.en.md
b/docs/document/content/user-manual/shardingsphere-jdbc/special-api/transaction/spring-namespace.en.md
index 09bee4b54bf..ccc9dc59a6e 100644
---
a/docs/document/content/user-manual/shardingsphere-jdbc/special-api/transaction/spring-namespace.en.md
+++
b/docs/document/content/user-manual/shardingsphere-jdbc/special-api/transaction/spring-namespace.en.md
@@ -3,7 +3,13 @@ title = "Use Spring Namespace"
weight = 3
+++
-## Import Maven Dependency
+## Background
+
+ShardingSphere-JDBC can be used through spring namespace.
+
+## Prerequisites
+
+Introducing Maven denpendency
```xml
<dependency>
@@ -12,14 +18,21 @@ weight = 3
<version>${shardingsphere.version}</version>
</dependency>
-<!-- import if using XA transaction -->
+<!-- This module is required when using XA transactions -->
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-transaction-xa-core</artifactId>
<version>${shardingsphere.version}</version>
</dependency>
-<!-- import if using BASE transaction -->
+<!-- This module is required when using XA's Narayana mode -->
+<dependency>
+ <groupId>org.apache.shardingsphere</groupId>
+ <artifactId>shardingsphere-transaction-xa-narayana</artifactId>
+ <version>${project.version}</version>
+</dependency>
+
+<!-- This module is required when using BASE transactions -->
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-transaction-base-seata-at</artifactId>
@@ -27,10 +40,17 @@ weight = 3
</dependency>
```
-## Configure Transaction Manager
+## Procedure
+
+1. Configure the transaction manager
+2. Use distributed transactions
+
+## Sample
+
+### Configure the transaction manager
```xml
-<!-- ShardingDataSource configuration -->
+<!-- Configuration of ShardingDataSource -->
<!-- ... -->
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
@@ -41,20 +61,20 @@ weight = 3
</bean>
<tx:annotation-driven />
-<!-- Enable auto scan @ShardingSphereTransactionType annotation to inject the
transaction type before connection created -->
+<!-- Enable automatic scanning of @ShardingSphereTransactionType annotation
and use Spring's native AOP for class and method enhancements -->
<sharding:tx-type-annotation-driven />
```
-## Use Distributed Transaction
+### Use distributed transactions
```java
@Transactional
-@ShardingSphereTransactionType(TransactionType.XA) // Support
TransactionType.LOCAL, TransactionType.XA, TransactionType.BASE
+@ShardingSphereTransactionType(TransactionType.XA) // support
TransactionType.LOCAL, TransactionType.XA, TransactionType.BASE
public void insert() {
- jdbcTemplate.execute("INSERT INTO t_order (user_id, status) VALUES (?,
?)", (PreparedStatementCallback<Object>) ps -> {
+ jdbcTemplate.execute("INSERT INTO t_order (user_id, status) VALUES (?,
?)", (PreparedStatementCallback<Object>) ps -> {
ps.setObject(1, i);
ps.setObject(2, "init");
ps.executeUpdate();
- });
-}
+ });
+ }
```