How to design global distributed transaction(none database)? Can JTA use for none db transaction?

前端 未结 3 2131
刺人心
刺人心 2020-12-13 11:00

I think this is a fairly common question: how to put my business logic in a global transaction in distributed systems environment? Cite an example, I have a TaskA containing

3条回答
  •  情歌与酒
    2020-12-13 11:22

    You're right, you need two-phase commit support thanks to a XA transaction manager provided by the JTA API.

    As far as I know Spring does not provide a transaction manager implementation itself. The JtaTransactionManager only delegates to existing implementation usually provided from JavaEE implementations.

    So you will have to plugin a JTA implementation into Spring to get effective job done. Here are some proposals:

    • JOTM
    • JBossTS based on Arjuna.
    • Atokimos

    Then you will have to implement your resource manager to support two-phase commit. In the JavaEE worlds, it consists in a resource adapter packaged as a RAR archive. Depending on the type of resource, the following aspects are to read/implement:

    • XAResource interface
    • JCA Java Connector Architecture mainly if a remote connection is involved
    • JTS Transaction Service if transaction propagation between nodes is required

    As examples, I recommend you to look at implementations for the classical "transactions with files" issue:

    • the transactional file manager from JBoss Transactions
    • XADisk project

提交回复
热议问题