AnsweredAssumed Answered

Jta Transactions

Question asked by hakanskucuk on Oct 19, 2011
Latest reply on Oct 26, 2011 by hakanskucuk
Hi,
We are using spring, jpa(Hibernate), activiti and jms together. Activiti and Jpa uses the same datasource (mysql).
To manage transactions we use XA datasource and Atomikos transaction manager.

In bpm events and expressions we update some of our jpa entities.

When we update jpa entities and start processes that updates the same entities we get transaction timeouts  due to locks.


The configuration files we use are below. Did we configure them correctly?


<bean id="jtaDataSource" class="com.atomikos.jdbc.AtomikosDataSourceBean"
      init-method="init" destroy-method="close">
      <property name="uniqueResourceName" value="${hibernate.connection.database}" />
      <property name="xaDataSourceClassName" value="com.mysql.jdbc.jdbc2.optional.MysqlXADataSource" />
      <property name="xaProperties">
         <props>
            <prop key="URL">${hibernate.connection.url}</prop>
            <prop key="user">${hibernate.connection.username}</prop>
            <prop key="password">${hibernate.connection.password}</prop>
            <prop key="pinGlobalTxToPhysicalConnection">true</prop>
         </props>
      </property>
      <property name="maxPoolSize" value="50" />
      <property name="minPoolSize" value="20" />
   </bean>

   <bean id="entityManagerFactory"
      class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
      <property name="persistenceUnitName" value="PU" />
      <property name="persistenceUnitManager" ref="persistenceUnitManager" />
      <property name="jpaDialect">
         <bean class="org.springframework.orm.jpa.vendor.HibernateJpaDialect" />
      </property>
      <property name="jpaVendorAdapter">
         <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
            <property name="showSql" value="${hibernate.show_sql}" />
            <property name="generateDdl" value="${hibernate.generateDdl}" />
            <property name="databasePlatform" value="${hibernate.dialect}" />
         </bean>
      </property>
      <property name="jpaProperties">
         <props>
            <prop key="hibernate.transaction.manager_lookup_class">com.atomikos.icatch.jta.hibernate3.TransactionManagerLookup
            </prop>
         </props>
      </property>
   </bean>


   <bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
      <property name="databaseType" value="mysql" />
      <property name="dataSource" ref="jtaDataSource" />
      <property name="transactionManager" ref="transactionManager" />
      <property name="databaseSchemaUpdate" value="false" />
      <property name="jpaEntityManagerFactory" ref="entityManagerFactory" />
      <property name="jpaCloseEntityManager" value="false" />
      <property name="jobExecutorActivate" value="false" />
   </bean>

<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">
      <property name="transactionTimeout" value="300" />
   </bean>

   <bean id="transactionManager"
      class="org.springframework.transaction.jta.JtaTransactionManager">
      <property name="transactionManager" ref="atomikosTransactionManager" />
      <property name="userTransaction" ref="atomikosUserTransaction" />
   </bean>

Outcomes