2PC transaction submit uses the DTP Model defined by X/OPEN, in which extracted
RM can guarantee a high transaction consistency.
RM exchange transaction information according to XA. Compared with traditional local transactions, XA transactions have a prepare phase, where the database can not only passively receive commands, but also notify the submitter whether the transaction can be accepted. So
TM can collect all the prepare results of transactions in branches before submitting all of them together, which has guaranteed the high consistency.
Java implements the XA model through defining a JTA interface, in which
ResourceManager requires an XA driver provided by database manufacturers and
TransactionManager is provided by transaction manager manufacturers. Traditional transaction managers need to be bound with application server, which poises a high use cost. But built-in transaction managers have already been able to provide services through jar packages. Integrated with ShardingSphere, it can guarantee the high consistency in cross-database transactions after sharding.
Usually, to use XA transaction, users must use its connection pool provided by transaction manager manufacturers. However, when ShardingSphere integrates XA transactions, it has separated the management of XA transaction and its connection pool, so XA will not invade the business.