Atomikos Forum

multiple datasources, one transaction manager, spring integratio

Hi there,

i am looking into how to set up transactions for a loosely coupled web-based administration system we're building, and am wondering about whether atomikos can be used in our scenario:

We have 2(potentially more in the future) data sources, and a generic "job" class that is to execute tasks against these datasources. The tasks are configured in a database (including which datasource to use) and read up in run-time.

The task can either be a set of sql commands against datasource1, or datasource2.

We have traditionally used spring's built-in functionality for transaction management, but that one can only be set up against one specific data source.

What i'd like is to be able to configure a transactionmanager against both(all) data sources, use @transactional annotation on the job class method and the transaction manager would manage the transaction regardless of which one of the 2 datasources that is used inside the method.

Is this feasible? Any input would be appreciated.

(I don't really need XA-support, i just want to make sure that all sql within each datasource is handled within a transaction)
Mathias af Jochnick Send private email
Friday, April 24, 2009
Sure this sounds like no problem...
Guy Pardon Send private email
Friday, April 24, 2009
hi mathias,

I think, using atomikos here is a little bit oversized. I would prefer using spring declarative transaction management by defining AOP proxies with different transaction manager instances.

  <tx:advice id="txAdvice" transaction-manager="txManager">
  <!-- the transactional semantics... -->
    <!-- all methods starting with 'get' are read-only -->
    <tx:method name="get*" read-only="true"/>
    <!-- other methods use the default transaction settings (see below) -->
    <tx:method name="*"/>

...and once again...
  <tx:advice id="..." ...>
see spring reference:

That should work - ok you have to give up the sexy @Transactional annotation :-/

Martin Bengl Send private email
Friday, April 24, 2009

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics