Atomikos Forum

Declarative transaction management withSynchronization

Hi,

I'm trying to setup a standalone java project, which uses spring transaction management feature. My application is all set up and now i want to apply transaction management feature using @Transactional annotation. Here am worried whether there is a way to configure Synchronization( or a factory) along with spring/atomikos transactionManager or userTransaction.
now all that i had to do is intercept each @transactionl method using spring aop, get the transaction and register a Synchronization. My transactional methods may involve subtransactional methods and i dont want to register a synchronization with all of my subtransactions, which is a performance issue.

does spring/atomikos manage Transaction synchronizations too?

somewhere in the atomikos logs i could see info as,

681 [main] INFO atomikos - registerSynchronization ( com.atomikos.jdbc.AtomikosConnectionProxy$JdbcRequeueSynchronization@a800952b ) for transaction tm0000100157
713 [main] INFO atomikos - registerSynchronization ( com.atomikos.jdbc.AtomikosConnectionProxy$JdbcRequeueSynchronization@a800952b ) for transaction tm0000100157

can we pass our custom synchronization obj to be registered here?.


Please help me out of this, your response is appreciated.
Thanks in advance,

my configuration looks like,


<tx:jta-transaction-manager />
    <tx:annotation-driven  transaction-manager="transactionManager"/>

<bean id="AtomikosTransactionManager"  class="com.atomikos.icatch.jta.UserTransactionManager" 
    init-method="init" destroy-method="close">
     
  <property name="forceShutdown" value="false" />   
</bean>
 
<bean id="AtomikosUserTransaction" class="com.atomikos.icatch.jta.UserTransactionImp">

<bean id="transactionManager" 
      class="org.springframework.transaction.jta.JtaTransactionManager">
  <property name="transactionManager" ref="AtomikosTransactionManager" />
  <property name="userTransaction" ref="AtomikosUserTransaction" />
</bean>
shivakanth Send private email
Monday, June 06, 2011
 
 
Try something like:

//get handle to transaction manager
UserTransactionManager utm = new UserTransactionManager();

//retrieve transaction for thread
Transaction tx = utm.getTransaction();

//create your synchronisation object
Synchronisation s = new ...;

//register in current tx
tx.registerSynchronisation(s);

HTH
Guy Pardon Send private email
Monday, June 06, 2011
 
 
Typo:

Synchronisation -> Synchronization in all of the above lines of code...
Guy Pardon Send private email
Monday, June 06, 2011
 
 
Thanks pardon,

In fact, that's only i've tried but i want atomikos to handle this, instead of i create synchronization and register programtically. By giving a factory of synchronizations or like that.
Actually, the problem with programtical synchronization management is subtransaction that my application's got.

Is there any way to get this thing done declaratively?.
shivakanth Send private email
Monday, June 06, 2011
 
 
Not sure I understand your problem with programmatic registration, but AFAIK there is no other way...
Guy Pardon Send private email
Monday, June 06, 2011
 
 
Actually, there are over 200 service classes with @Transactional methods in them, and possibilities are that one transactional method may call many methods(subtransactions). here when i'm trying to intercept these transactional methods and register a synchronization programatically, the subtransactional methods also being intercepted and an extra overhead of registering a synchronization happens which is a perfomance issue for my application. I am looking for a sutable way to get around this.
shivakanth Send private email
Tuesday, June 07, 2011
 
 
Hi,

Sorry for my ignorance, but with a factory you would have the same kind of "overhead"? I mean: the code to register must surely be defined somewhere, in your AOP class or elsewhere?
Guy Pardon Send private email
Wednesday, June 08, 2011
 
 
Do you really need at all 200 methods a synchronization? I guess there are some resource methods which do need them. You can than write your own aspect which does only apply to those methods.
Where the code goes factroy, aspect inline etc.) is up to you.

If you really need syncs on about 200 methods ... imho your resources are not well designed than, from my "far" point of view.
Torsten Krah Send private email
Tuesday, June 14, 2011
 
 

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

Other recent topics Other recent topics