Atomikos Forum |
|
I am using Oracle Active Queueing in combination with Atomikos on Tomcat. Transactions are defined by Spring AOP. When I want to send a message to the Oracle JMS queue, I get raised -7: the XA resource has become unavailable. This happens at the time when the transaction manager tries to commit. I have tried setting com.atomikos.icatch.serial_jta_transactions=false, but that does not help. Any idea what I am doing wrong?
Configuration:
context.xml entry: <Resource name="jdbc/SPRT_XA" auth="Container" type="oracle.jdbc.xa.client.OracleXADataSource" driverClassName="oracle.jdbc.xa.client.OracleXADataSource" factory="oracle.jdbc.pool.OracleDataSourceFactory" url="..." user="..." password="..." maxIdle="10" maxWait="-1" maxActive="20"/> Datasource def in Spring <bean id="datasource.HORADataSourceSPRT_XA" class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="jndiName" value="java:comp/env/jdbc/SPRT_XA"/> </bean> <bean id="AtomikosDataSource.SPRT" class="com.atomikos.jdbc.AtomikosDataSourceBean"> <property name="xaDataSource" ref="datasource.HORADataSourceSPRT_XA"/> <property name="uniqueResourceName" value="AtomikosDataSource.SPRT"/> <property name="maxPoolSize" value="20"/> <property name="minPoolSize" value="5"/> </bean> Factory beans: <bean id="aqConnectionFactoryInitialiser" class="be.admb.webservices.jms.oracle.OracleAqConnectionFactoryInitialiser"> <property name="dataSource" ref="datasource.HORADataSourceSPRT_XA"/> </bean> <bean id="aqConnectionFactory" factory-bean="aqConnectionFactoryInitialiser" factory-method="createConnectionFactory" > </bean> JmsTemplate: <bean id="jmsTemplateOracle" class="org.springframework.jms.core.JmsTemplate"> <property name="connectionFactory" ref="aqConnectionFactory"/> <property name="receiveTimeout" value="30000"/> </bean>
Code
===Connection Factory Initialiser=== import javax.jms.ConnectionFactory; import javax.jms.XAQueueConnectionFactory; import javax.sql.DataSource; import javax.sql.XADataSource; import oracle.jms.AQjmsFactory; import org.springframework.util.Assert; import com.atomikos.jms.QueueConnectionFactoryBean; public class OracleAqConnectionFactoryInitialiser { private DataSource dataSource; public DataSource getDataSource() { return dataSource; } public void setDataSource(DataSource dataSource) { this.dataSource = dataSource; } public ConnectionFactory createConnectionFactory() throws Exception { Assert.isInstanceOf(XADataSource.class, dataSource); XAQueueConnectionFactory xacf = AQjmsFactory.getXAQueueConnectionFactory((XADataSource) dataSource); QueueConnectionFactoryBean qcf = new QueueConnectionFactoryBean(); qcf.setResourceName("XA_ORACLE_QUEUE"); qcf.setXaQueueConnectionFactory(xacf); return qcf; } } ===Queue factory bean=== import javax.jms.QueueConnection; import javax.jms.QueueConnectionFactory; import javax.jms.QueueSession; import org.springframework.beans.factory.FactoryBean; public class OracleAqDestinationFactoryBean implements FactoryBean { private QueueConnectionFactory connectionFactory; private String queueName; private String queueUser; public void setConnectionFactory(QueueConnectionFactory connectionFactory) { this.connectionFactory = connectionFactory; } public void setQueueName(String queueName) { this.queueName = queueName; } public void setQueueUser(String queueUser) { this.queueUser = queueUser; } public Object getObject() throws Exception { // createQueueSession(true,0) - create a transactional session QueueConnection qc=connectionFactory.createQueueConnection(); QueueSession session = qc.createQueueSession(true, 0); return session.createQueue( queueUser+"."+queueName); } public Class getObjectType() { return javax.jms.Queue.class; } public boolean isSingleton() { return false; } }
Logging
Atomikos:3 [Fri Apr 10 12:50:00 CEST 2009] AQjmsXAResource.commit: enter: xid=HORA_WS_POC_ATOMIKOS0000200162HORA_WS_POC_ATOMIKOS2 onePhase=true Atomikos:3 [Fri Apr 10 12:50:00 CEST 2009] AQjmsXAResource.commit: Exception: oracle.jdbc.xa.OracleXAException oracle.jdbc.xa.OracleXAException at oracle.jdbc.xa.OracleXAResource.checkError(OracleXAResource.java:1337) at oracle.jdbc.xa.client.OracleXAResource.commit(OracleXAResource.java:676) at oracle.jms.AQjmsXAResource.commit(AQjmsXAResource.java:69) at com.atomikos.datasource.xa.XAResourceTransaction.commit(XAResourceTransaction.java:957) at com.atomikos.icatch.imp.CommitMessage.send(CommitMessage.java:94) at com.atomikos.icatch.imp.PropagationMessage.submit(PropagationMessage.java:86) at com.atomikos.icatch.imp.Propagator$PropagatorThread.run(Propagator.java:62) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:619) WARN [atomikos] XA resource 'XA_ORACLE_QUEUE': commit for XID '484F52415F57535F504F435F41544F4D494B4F5330303030323030313632:484F52415F57535F504F435F41544F4D494B4F5332' raised -7: the XA resource has become unavailable oracle.jdbc.xa.OracleXAException at oracle.jdbc.xa.OracleXAResource.checkError(OracleXAResource.java:1337) at oracle.jdbc.xa.client.OracleXAResource.commit(OracleXAResource.java:676) at oracle.jms.AQjmsXAResource.commit(AQjmsXAResource.java:69) at com.atomikos.datasource.xa.XAResourceTransaction.commit(XAResourceTransaction.java:957) at com.atomikos.icatch.imp.CommitMessage.send(CommitMessage.java:94) at com.atomikos.icatch.imp.PropagationMessage.submit(PropagationMessage.java:86) at com.atomikos.icatch.imp.Propagator$PropagatorThread.run(Propagator.java:62) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:619) WARN [atomikos] Unexpected error in commit com.atomikos.icatch.SysException: XA resource 'XA_ORACLE_QUEUE': commit for XID '484F52415F57535F504F435F41544F4D494B4F5330303030323030313632:484F52415F57535F504F435F41544F4D494B4F5332' raised -7: the XA resource has become unavailable at com.atomikos.datasource.xa.XAResourceTransaction.commit(XAResourceTransaction.java:998) at com.atomikos.icatch.imp.CommitMessage.send(CommitMessage.java:94) at com.atomikos.icatch.imp.PropagationMessage.submit(PropagationMessage.java:86) at com.atomikos.icatch.imp.Propagator$PropagatorThread.run(Propagator.java:62) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:619)
Hi Guy,
Found the cause of the problem. I needed to set the sessionTransacted property to true on the JmsTemplate. See below: <bean id="jmsTemplateOracle" class="org.springframework.jms.core.JmsTemplate"> <property name="connectionFactory" ref="aqConnectionFactory"/> <property name="receiveTimeout" value="30000"/> <property name="sessionTransacted" value="true"/> </bean> It all makes sense now. Regards, Rik |