XA transaction for two phase commit

2019-08-17 01:15发布

问题:

hi,

If two resources are involved in a transaction then the XA transation setting should be enabled in the weblogic server. Then the xa drivers has to be chosed.Is there a alternative way to have this two resources in a transaction without enabling XA transaction

回答1:

Yes, you can use Global Transaction Emulation. WebLogic has two mode:

  • Logging Last Resource - WebLogic creates a table into all your datasources and write transactions data into this table. This is a preference option.

From official documentation:

With this option, the transaction branch in which the connection is used is processed as the >last resource in the transaction and is processed as a local transaction. Commit records for >two-phase commit (2PC) transactions are inserted in a table on the resource itself, and the >result determines the success or failure of the prepare phase of the global transaction. >This option offers some performance benefits and greater data safety than Emulate Two-Phase >Commit, but it has some limitations.

see http://docs.oracle.com/cd/E15051_01/wls/docs103/jta/llr.html

  • Emulate Two-Phase Commit - transaction branch always return "SUCCESS" while prepare phase. Select this option if your app can tolerant heuristic conditions.

see http://docs.oracle.com/cd/E23943_01/web.1111/e13737/transactions.htm for more information.

I prefer LLR option, but if you work with legacy DB and do not have the table create grant, you should use two-phase commit emulation.