Mysql complaint mysql xa datasource and Atomikos connection pooling
<bean id="dataSource" class="com.atomikos.jdbc.AtomikosDataSourceBean" init-method="init" destroy-method="close"> <property name="uniqueResourceName" value="MAIN-ATOMIKOS-CONNECTION" /> <property name="poolSize" value="${initialSize}" /> <property name="xaDataSourceClassName" value="com.mysql.jdbc.jdbc2.optional.MysqlXADataSource" /> <property name="xaProperties" ref="databaseProperties" /> <property name="testQuery" value="select 1" /> </bean>
database.properties
<util:properties id="databaseProperties" location="classpath:database.properties" />
url=jdbc\:mysql\://localhost\:3306/<DBNAME>
user=root
password=
autoReconnect=true
autoReconnectForConnectionPools=true
autoReconnectForPools=true
pinGlobalTxToPhysicalConnection=true
Transaction specific Config
Following settings are for enabling transactions
<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>true</value> </property> </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 bean="atomikosTransactionManager" /> </property> <property name="userTransaction"> <ref bean="atomikosUserTransaction" /> </property> </bean>
Just adding spring Spring annotation - will now enable transaction on required methods.