Announcement Announcement Module
Collapse
No announcement yet.
Spring config for Spring Transaction + MYSQL XA Datsource + DBCP pooling + Jboss TM Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring config for Spring Transaction + MYSQL XA Datsource + DBCP pooling + Jboss TM

    Hi All,

    I am trying to use the following for my spring application

    1. Spring transaction support with annotations(JTA)

    2. Jboss Transaction manager

    3. DBCP connection pooling

    4. Mysql XA datasource (i am using another cache which forces me to use XA)


    I am slightly confused with teh configurations , can any1 help me with the same

    To set up the datasource i use the following

    <bean id="mysqlXADataSource" class="com.mysql.jdbc.jdbc2.optional.MysqlXADataSo urce">
    <property name="user" value="${user}" />
    <property name="password" value="${password}"/>
    <property name="url" value="${url}"/>
    </bean>


    <bean id="dsConnectionFactory" class="org.apache.commons.dbcp.managed.DataSourceX AConnectionFactory">
    <constructor-arg><ref bean="transactionManager"/></constructor-arg>
    <constructor-arg><ref bean="mysqlXADataSource"/></constructor-arg>
    </bean>


    <bean id="pool" class="org.apache.commons.pool.impl.GenericObjectP ool">
    <property name="minEvictableIdleTimeMillis"><value>300000</value></property>
    <property name="timeBetweenEvictionRunsMillis"><value>60000</value></property>
    <property name="factory" ref="poolableConnectionFactory"/>
    </bean>


    <bean id="poolableConnectionFactory" class="org.apache.commons.dbcp.PoolableConnectionF actory">
    <constructor-arg index="0"><ref bean="dsConnectionFactory"/></constructor-arg>
    <constructor-arg index="1"><ref bean="pool"/></constructor-arg>
    <constructor-arg index="2"><null/></constructor-arg>
    <constructor-arg index="3"><null/></constructor-arg>
    <constructor-arg index="4"><value>false</value></constructor-arg>
    <constructor-arg index="5"><value>true</value></constructor-arg>
    </bean>


    <bean id="dataSource" class="org.apache.commons.dbcp.managed.ManagedData Source" depends-on="poolableConnectionFactory">
    <constructor-arg><ref bean="pool"/></constructor-arg>
    <constructor-arg><ref bean="#{dsConnectionFactory.getTransactionRegistry ()}"/></constructor-arg>
    </bean>



    And my transaction manager config looks like this


    <bean id="jbossTransactionManager"
    class="com.arjuna.ats.internal.jta.transaction.arj unacore.TransactionManagerImple">
    </bean>

    <bean id="jbossUserTransaction"
    class="com.arjuna.ats.internal.jta.transaction.arj unacore.UserTransactionImple" />


    <bean id="transactionManager"
    class="org.springframework.transaction.jta.JtaTran sactionManager">
    <property name="transactionManager">
    <ref bean="jbossTransactionManager"></ref>
    </property>
    <property name="userTransaction">
    <ref bean="jbossUserTransaction" />
    </property>
    </bean>



    I have th3 following doubts abt these configs


    1. dsConnectionFactory bean takes in transaction manager as parameter - so i cannot inject spring jta tm , since it doest implement javax.transaction.TransactionManager

    Should i be pluggin in the jbossUserTransaction ?

    2. Am i right in my bean definition to say

    <constructor-arg><ref bean="#{dsConnectionFactory.getTransactionRegistry ()}"/></constructor-arg>


    Does this kind a syntax make sense with Spring EL ?


    ref : http://lafernando.com/2011/01/05/xa-...cp/#comment-30

  • #2
    I think i got teh answer to my first question , i do have to inject jtaTransactionManager.getTransactionManager().

    Comment

    Working...
    X