shardingsphere icon indicating copy to clipboard operation
shardingsphere copied to clipboard

Using @ShardingTransactionType(TransactionType.XA) does not work

Open xfyang1989 opened this issue 7 years ago • 14 comments

Using @ShardingTransactionType(TransactionType.XA) does not work,how to configure, the error is as follows:, Cause: java.lang.IllegalStateException: Missing the data source name: 'rw0' at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:79) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:447) at com.sun.proxy.$Proxy52.selectOne(Unknown Source)

xfyang1989 avatar Mar 12 '19 02:03 xfyang1989

hi, please read the document https://shardingsphere.apache.org/document/legacy/3.x/document/cn/manual/sharding-jdbc/usage/transaction/

cherrylzhao avatar Mar 12 '19 02:03 cherrylzhao

this is my configure:

<sharding:data-source id="shardingDataSource">
        <sharding:sharding-rule data-source-names="rw0,rw1" default-data-source-name="rw0">
            <sharding:table-rules>
                <sharding:table-rule logic-table="ic_sku_channel_inventory" actual-data-nodes="rw$->{0..1}.ic_sku_channel_inventory_$->{0..15}" 
                     database-strategy-ref="databaseShardingStrategy" table-strategy-ref="tableShardingStrategy"/>
            </sharding:table-rules>
        </sharding:sharding-rule>
       <sharding:props>
             <prop key="sql.show">true</prop>
        </sharding:props>
    </sharding:data-source>

<import resource="classpath:META-INF/shardingTransaction.xml"/>

@ShardingTransactionType(TransactionType.XA) @Transactional public void freezeInventory(SKUBizInvFreezeSo bizInvFreezeSo){}

My MySQL driver : mysql-connector-java-5.1.45.jar I configured it according to the documentation you said,But,Using @ShardingTransactionType(TransactionType.XA) does not work,the above error occurred

xfyang1989 avatar Mar 12 '19 02:03 xfyang1989

please give me a entire namespace xml configuration. or you can read our example in tag 3.1.0 https://github.com/apache/incubator-shardingsphere-example/tree/3.1.0/sharding-jdbc-example/spring-namespace-nodep-example/spring-namespace-nodep-mybatis-example

cherrylzhao avatar Mar 12 '19 03:03 cherrylzhao

I debug it, suggesting this error.

Failed to wrap XADataSource to transactional datasource pool

xfyang1989 avatar Mar 12 '19 03:03 xfyang1989

what datasource are you using? how can i reproduce your error in my local environment. would you please push a demo project to GitHub?

cherrylzhao avatar Mar 12 '19 03:03 cherrylzhao

I suggest that you can make a demo based on spring-namespace about the configuration of distributed transactions. In addition, I feel that many of your documents are not very detailed and complete.

xfyang1989 avatar Mar 12 '19 03:03 xfyang1989

datasource : hikariCP

xfyang1989 avatar Mar 12 '19 03:03 xfyang1989

I have provide our spring-namespace-demo with XA transaction to you, it is OK.

cherrylzhao avatar Mar 12 '19 03:03 cherrylzhao

I used your ShardingSphere in the project. The company has monitoring and does not allow uploading demos. I configured it according to your documentation, which is the error reported above.

this is spring-namespace-demo with XA transaction ???? https://github.com/apache/incubator-shardingsphere-example/tree/3.1.0/sharding-jdbc-example/spring-namespace-nodep-example/spring-namespace-nodep-mybatis-example

xfyang1989 avatar Mar 12 '19 03:03 xfyang1989

yes, first, please run SpringNamespaceTransactionExample, it include XA transaction type.

cherrylzhao avatar Mar 12 '19 03:03 cherrylzhao

ok,I try it ,3Q

xfyang1989 avatar Mar 12 '19 03:03 xfyang1989

Also, when will the version of your ShardingSphere4.0.0 be released?

xfyang1989 avatar Mar 12 '19 07:03 xfyang1989

apache release need a long time, maybe 3 moth

cherrylzhao avatar Mar 12 '19 08:03 cherrylzhao

I will mark this issue with invalid, it is your environment problem.

cherrylzhao avatar Mar 20 '19 03:03 cherrylzhao