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。
- Copy the jar file required by Narayana to
conf/lib
. The reference package is as follows:
<properties>
<narayana.version>5.9.1.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>
<dependency>
<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>
</dependency>
<dependency>
<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>
</dependency>
- Configure
xa-transaction-manager-type
inconf/server.yaml
:
- !TRANSACTION
defaultType: XA
providerType: Narayana
- Add
jbossts-properties.xml
to customize Narayana configuration. The order of path loading isuser.dir (pwd)
>user.home
>java.home
>classpath
. Please refer to Narayana official documentation for more details.
- Use Bitronix XA Transaction Manager。
- Copy the jar file required by Bitronix to
conf/lib
. The reference package is as follows:
<properties>
<btm.version>2.1.3</btm.version>
</properties>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-transaction-xa-bitronix</artifactId>
<version>${shardingsphere.version}</version>
</dependency>
<dependency>
<groupId>org.codehaus.btm</groupId>
<artifactId>btm</artifactId>
<version>${btm.version}</version>
</dependency>
- Configure
xa-transaction-manager-type
inconf/server.yaml
:
- !TRANSACTION
defaultType: XA
providerType: Bitronix
- 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
.
当前内容版权归 ShardingSphere 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 ShardingSphere .