The pitfalls encountered when using atomikos multi-data source transactions

question:

    When testing the rollback of atomikos multi-data source transaction, use throw new Exception("xxxx") to simulate system exception, and then the transaction has not been rolled back.

reason:

    After a long time, I found out that using  throw new Exception("xxxx") will not roll back,

    But you can use  throw new RuntimeException("xxxxxxxxxxxx");    to simulate system exceptions, so that atomikos multi-data source transactions will be rolled back!

    Or write some code that cannot be executed normally to simulate system exceptions, such as: String a = null; a.toString(); 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324607733&siteId=291194637