1. xa-datasource
- XADataSource is a feature of the JDBC 2.0 Optional Package (formerly Standard Extension API).
- If you're clustering your application servers or wanting to use distributed transactions among multiple application servers, then you should use
. - XA gets involved when you want to work with multiple resources, ex:
- 2 or more databases
- a database and a JMS connection
- all of those plus maybe a JCA resource - all in a single transaction. (?)
- Most stuff in the world is non-XA, ex:
- a Servlet or EJB or plain old JDBC in a Java application talking to a single database.
Two Phase Commit (2PC)
- 分散式資料庫為保持各個資料庫數據一致的協定。
- 對於分散式資料庫系統來說,因為資料庫的資料是分散儲存在各地的資料庫伺服器,當交易需要執行交付時,如果馬上執行,若任何一個資料庫伺服器沒有完成交付,就有可能造成整個分散式資料庫的資料不一致。
- 也支援 individual resource。
- 概念為一個失敗則全部失敗。
- 將交付分為兩個階段來執行。
Phases
1. 協調者(Coordinator)送出SECURE訊息給各資料庫伺服器,此時各資料庫伺服器交付分散儲存各處的資料庫伺服器可以執行交付,否則將放棄此交易。
2. 當各資料庫伺服器都回覆可執行交付後,協調者才送出交付訊息,讓各資料庫伺服器執行交付交易,並且回覆是否成功,如果有任何一個資料庫伺服器回覆錯誤,協調者就會送出復原訊息取消交易。
* Reference
- DataSource configuration
- 二階段交付
沒有留言:
張貼留言