You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2021/09/28 14:43:08 UTC

[GitHub] [shardingsphere] zhfeng commented on issue #12771: how to use xa transaction in shardingsphere-proxy

zhfeng commented on issue #12771:
URL: https://github.com/apache/shardingsphere/issues/12771#issuecomment-929297993


   @roodkcab it needs to use a mysql XA DataSource class such as ```com.mysql.cj.jdbc.MysqlXADataSource```. All of the transaction operations should be handled by mysql driver. So in your application, you just need to
   ```java
   TransactionManager tm;
   
   tm.begin();
   try {
       do_some_insert_sql();
       other_process(); // just like send a message to AMQ
       tm.commit();
   } catch (Exception e) {
       tm.rollback();
   }
   ```
   
   Or if you use some framework, such as Spring, Spring-Boot or Wildfly, the container will manage the tarnsaction process. You just need to 
   ```java
   @Transactional
   void process() {
       do_some_insert_sql();
       other_process();
   }
   ```
   
   In term of the sharding-proxy, @RaigorJiang I belive that it should bypass the xa related commands and route to the backend servers ? Is there any test for this XA scenario ?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org