Announcement Announcement Module
Collapse
No announcement yet.
Declarative Transaction while using JOTM Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Declarative Transaction while using JOTM

    Hi,
    I have having some problem while using Declarative transaction. I am
    using JOTM as we have to deal with 2 different resources ASA / Oracle.

    My bussiness Object looks like:
    ------ Replication.java --------------------

    public void replicateTable(pram1,pram1.) throws DataAccessException{
    runPreprocess(procedureName)
    doDataTransfer(srcTable,dstTable);
    runPostProcess(procedureName);


    }

    private runPreprocess(procedureName) throws DataAccessException{
    result = asaDao.runProcess(procedureName);
    if (result == o) throw new DBException("Pre process Failed");
    }


    private doDataTransfer(tabName1,tabName2) throws DataAccessException{
    asaDao.readData(tabName1);
    oracleDao.writeData(tabName2);
    }

    private runPostProcess(procedureName) throws DataAccessException{
    result = oracleDao.runProcess(procedureName);
    if (result == o) throw new DBException("Pre process Failed");
    }

    ----END of Replication.java --------------------

    --------------Dao -------------------------
    public List readData(tableName) throws DataAccessException{
    JdbcTemplate jdbc = new JdbcTemplate(this.dataSource);
    return jdbc.query(sql,params,new myHandler());
    }

    public int[] writeData(tableName,data) throws DataAccessException{
    JdbcTemplate jdbc = new JdbcTemplate(this.dataSource);
    jdbc.batchUpdate(sql,new BatchSetter(data));
    }

    public String runProcess(processName) throws DataAccessException{
    JdbcTemplate jdbc = new JdbcTemplate(this.dataSource);
    Process pr = new Process(this.dataSource,processName);
    return pr.execute();
    }

    ------------END of DAO ----------------------

    ------------------jReplication.xml -----------------

    <bean id="asaDao" class="com.osg.jreplication.dao.impl.ReplicationDa o">
    <property name="dataSource">
    <ref local="asaDataSource"/>
    </property>
    </bean>

    <bean id="oraDao" class="com.osg.jreplication.dao.impl.ReplicationDa o" >
    <property name="dataSource">
    <ref local="oracleDataSource"/>
    </property>
    </bean>

    <bean id="jReplication" class="com.osg.jreplication.process.Replication">
    <property name="asaReplicationDao">
    <ref bean="asaDao"/>
    </property>
    <property name="oraReplicationDao">
    <ref bean="oraDao"/>
    </property>
    <property name="oraSetUpDao">
    <ref bean="setUpDao"/>
    </property>
    <property name="rowsUpperLimit">
    <value>${maxRow.limit}</value>
    </property>
    </bean>


    <bean id="repTransactionManager" class="org.springframework.transaction.jta.JtaTran sactionManager">
    <property name="userTransaction">
    <ref bean="jotm"/>
    </property>
    </bean>

    <bean id="repBusinessObject" class="org.springframework.transaction.interceptor .TransactionProxyFactoryBean">
    <property name="transactionManager">
    <ref bean="repTransactionManager"/>
    </property>
    <property name="target">
    <bean class="com.osg.jreplication.process.Replication"/>
    </property>
    <property name="transactionAttributes">
    <props>
    <prop key="replicateTable">PROPAGATION_REQUIRED,-DataAccessException,-DBException</prop>
    </props>
    </property>
    </bean>

    -------------- END of jReplication.xml -------


    My problem is Declarative transaction is not working. In above code when
    PostProcess fails, data written is not rolled back.

    Is there any thing wrong in above configuration, or am I am over looking some thing here.?

    Please help. Any suggestion will be much appreciated.

    Thanks in advance.
    Sanjeev[/list]

  • #2
    Hi again,
    When I switched the debug On is see that
    [org.enhydra.jdbc.xapool] [debug] - StandardXAConnectionHandle:close globalTransaction='false' con.getAutoCommit='true' ttx='null'

    This means global Transaction is not ON. Just to experiment a little bit I changes configuration as below.

    <bean id="repBusinessObjectTarget" class="com.osg.jreplication.process.Replication"/>

    <bean id="repTransactionInterceptor" class="org.springframework.transaction.interceptor .TransactionInterceptor">
    <property name="transactionManager">
    <ref bean="repTransactionManager"/>
    </property>
    <property name="transactionAttributes">
    <value>
    com.osg.jreplication.process.Replication.replicate Table=PROPAGATION_REQUIRED,-DataAccessException,-DBException
    </value>
    </property>
    </bean>

    <bean id="repBusinessObject" class="org.springframework.aop.framework.ProxyFact oryBean">
    <property name="interceptorNames">
    <value>repTransactionInterceptor,repBusinessObject Target</value>
    </property>
    </bean>

    also in DAO I changed in such a way that the same jdbcTemplate is re-used instead of creating every time new in every method.

    But the end result it is still not working.

    Look forward to your help. Please...

    Regards

    Comment

    Working...
    X