Spring multiple transaction managers, single transaction

前端 未结 3 491
抹茶落季
抹茶落季 2020-12-30 12:34

I have a complex situation where I have to use 2 different databases, there for I use 2 different transaction managers. Is there a way in Spring to link these transaction ma

3条回答
  •  不知归路
    2020-12-30 13:28

    You can use Spring's JtaTransactionManager to make sure both DBs are transacted with a single transaction manager.

    Note, you would have to choose an underlying implementation which can either be a container's one: e.g. WebLogic, WebSphere and OC4J, etc.. or a stand alone, even an open source one: e.g. Atomikos.

    HOWEVER

    XA transaction management complicates things (configuration / performance / problem resolution / maintenance / etc.). And in a lot of cases, it can be avoided by clever patterns.

    To get a solid understanding on whether you need to use XA ( e.g. distributed ) transaction manager, take a look at this fantastic article by Spring's own Dave Syer: Distributed transactions in Spring, with and without XA

提交回复
热议问题