Atomikos Forum

XA management between MQ and Oracle

Hello,

I'm currently working with atomikos and have some problems making my code working properly. I want to make some XA between MQ series and Oracle. Here is my code:

The file related to the Oracle database :
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:util="http://www.springframework.org/schema/util"
    xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context-3.2.xsd
        http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.2.xsd
        http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.2.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
        http://www.springframework.org/schema/util
        http://www.springframework.org/schema/util/spring-util-2.0.xsd">

    <context:property-placeholder location="configuration/myproperty.properties" ignore-unresolvable="true" />
        
    <bean id="jobRepository"
        class="org.springframework.batch.core.repository.support.JobRepositoryFactoryBean">
        <property name="transactionManager" ref="xaTransactionManager" />
        <property name="dataSource" ref="xaDataSource" />
        <property name="databaseType" value="Oracle" />
    </bean>

    <bean id="userTransactionManager" class="com.atomikos.icatch.jta.UserTransactionManager"
        init-method="init" destroy-method="close" depends-on="atomikosSystemProps">
        <property name="forceShutdown" value="false" />
    </bean>

    <bean id="userTransaction" class="com.atomikos.icatch.jta.UserTransactionImp" depends-on="atomikosSystemProps">
        <property name="transactionTimeout" value="300" />
    </bean>

    <bean id="xaTransactionManager" class="org.springframework.transaction.jta.JtaTransactionManager">
        <property name="transactionManager" ref="userTransactionManager" />
        <property name="userTransaction" ref="userTransaction" />
        <property name="allowCustomIsolationLevels" value="true" />
    </bean>

    <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
        <property name="dataSource" ref="xaDataSource" />
    </bean>
    
    <bean id="xaDataSource" class="com.atomikos.jdbc.AtomikosDataSourceBean"
        init-method="init" destroy-method="close" depends-on="atomikosSystemProps">
        <property name="uniqueResourceName" value="XA12" />
        <property name="xaDataSourceClassName" value="oracle.jdbc.xa.client.OracleXADataSource" />
        <property name="xaProperties">
            <props>
                <prop key="URL">myurl</prop>
                <prop key="user">myuser</prop>
                <prop key="password">mypassword</prop>
            </props>
        </property>
        <property name="poolSize" value="5" />
        <property name="testQuery" value="select 1 from dual" />
    </bean>

    <tx:annotation-driven proxy-target-class="true" transaction-manager="xaTransactionManager" />
    
    <bean id="atomikosSystemProps" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
        <property name="targetObject">
            <!-- System.getProperties() -->
            <bean
                class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
                <property name="targetClass" value="java.lang.System" />
                <property name="targetMethod" value="getProperties" />
            </bean>
        </property>
        <property name="targetMethod" value="putAll" />
        <property name="arguments">
            <!-- The new Properties -->
            <util:properties>
                <prop key="com.atomikos.icatch.hide_init_file_path">true</prop>
            </util:properties>
        </property>
    </bean>
</beans>


The file related to the MQ series queue:
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:util="http://www.springframework.org/schema/util"
    xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
        http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.2.xsd
        http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.2.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
        http://www.springframework.org/schema/util
        http://www.springframework.org/schema/util/spring-util-2.0.xsd">

    <bean id="atomikosConnectionFactory" class="com.atomikos.jms.AtomikosConnectionFactoryBean" init-method="init" destroy-method="close">
        <property name="xaConnectionFactory" ref="mqConnectionFactory" />
        <property name="uniqueResourceName" value="MQSeries_XA_RMI" />
    </bean>
    
    <bean id="mqConnectionFactory" class="com.ibm.mq.jms.MQXAConnectionFactory">
        <property name="queueManager" value="${batch.mq.fromopf.queuemanager}" />
        <property name="hostName" value="${batch.mq.fromopf.hostname}" />
        <property name="port" value="${batch.mq.fromopf.port}" />
        <property name="transportType" value="1" />
        <property name="channel" value="${batch.mq.fromopf.channel}" />
    </bean>
    
    <bean id="mqTransactionManager"
        class="org.springframework.transaction.jta.JtaTransactionManager">
        <property name="transactionManager" ref="atomikosTransactionManager" />
        <property name="userTransaction" ref="atomikosUserTransaction" />
    </bean>
    
    <bean id="atomikosTransactionManager" class="com.atomikos.icatch.jta.UserTransactionManager"
        init-method="init" destroy-method="close">
        <property name="transactionTimeout" value="120" />
        <property name="forceShutdown" value="true" />
    </bean>
    
    <bean id="atomikosUserTransaction" class="com.atomikos.icatch.jta.UserTransactionImp">
        <property name="transactionTimeout" value="300" />
    </bean>

    <bean id="transactionTemplate"
        class="org.springframework.transaction.support.TransactionTemplate">
        <property name="transactionManager" ref="mqTransactionManager" />
    </bean>
    
    <tx:annotation-driven proxy-target-class="true" transaction-manager="mqTransactionManager" />
</beans>

I get an error in my tests:
WARN atomikos - ERROR IN RECOVERY
com.atomikos.datasource.xa.jms.jmsTransactionalResource.refreshXAConnection(JmsTransactionalResource.java:97)

Can someone give me a hand please?
Hassen BOUIH Send private email
Monday, September 28, 2015
 
 
Hard to say without more information. You could try to set the uniqueResourceName to something a bit longer...

HTH
Guy Pardon Send private email
Wednesday, October 07, 2015
 
 

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

Other recent topics Other recent topics