Atomikos Forum

Extra Oracle connection when using AtomikosConnectionFactoryBean

Hi,

I have a test application which uses Atomikos 3.7 and Spring JMS 3.0.5.

I'm setting up a default message listener container to listen on an Oracle AQ.

This is the Spring config:

  <bean id="testXaDataSource" class="oracle.jdbc.xa.client.OracleXADataSource"
        destroy-method="close">
        <property name="user" value="user" />
        <property name="password" value="password" />
        <property name="URL" value="jdbc:oracle:oci:@test:1521:TESTDB" />
    </bean>

    <bean id="testXaFactory"
      class="com.lmco.uk.dt.persistence.oracle.OracleAqConnectionFactory">
      <property name="dataSource" ref="testXaDataSource" />
  </bean>

  <bean id="atomikosConnectionFactory" class="com.atomikos.jms.AtomikosConnectionFactoryBean" init-method="init" destroy-method="close">
          <property name="uniqueResourceName" value="test" />
          <property name="xaConnectionFactory" ref="testXaFactory" />
          <property name="minPoolSize" value="1" />
          <property name="maxPoolSize" value="5" />
  </bean>

  <bean id="testConnectionFactory" class="org.springframework.jms.connection.CachingConnectionFactory">
          <property name="sessionCacheSize" value="10" />
          <property name="targetConnectionFactory" ref="atomikosConnectionFactory" />
  </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="jtaTransactionManager"               
        class="org.springframework.transaction.jta.JtaTransactionManager">
        <property name="transactionManager" ref="atomikosTransactionManager" />
        <property name="userTransaction" ref="atomikosUserTransaction" />
  </bean>

  <bean id="messageListener" class="com.lmco.uk.dt.test.atomikos.TestMessageListener" />

    <bean id="messageListenerContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
      <property name="transactionManager" ref="jtaTransactionManager" />
      <property name="connectionFactory" ref="testConnectionFactory" />
      <property name="messageListener" ref="messageListener" />
      <property name="destinationName" value="TEST_Q" />
      <property name="concurrentConsumers" value="1" />
      <property name="receiveTimeout" value="3000" />
      <property name="sessionTransacted" value="true"/>
  </bean>

When I start up the application I would expect it to create 1 AQ connection but it's creating 3!

On debugging I can see it creates one connection for the Atomikos connection factory pool. 

I then get another connection created through the JmsTransactionalResource - see stack trace below:

    com.lmco.uk.dt.test.atomikos.TestMain at localhost:55039    
        Thread [main] (Suspended (breakpoint at line 96 in OracleAqConnectionFactory))    
            OracleAqConnectionFactory.createXAConnection(String, String) line: 96    
            OracleAqConnectionFactory.createXAConnection() line: 80    
            JmsTransactionalResource.refreshXAConnection() line: 113    
            JmsTransactionalResource(XATransactionalResource).getXAResource() line: 373    
            JmsTransactionalResource(XATransactionalResource).endRecovery() line: 655    
            TransactionServiceImp.recover() line: 635    
            JmsTransactionalResource(XATransactionalResource).setRecoveryService(RecoveryService) line: 503    
            Configuration.installRecoveryService(RecoveryService) line: 278    
            TransactionServiceImp.recover() line: 580    
            TransactionServiceImp.init(Properties) line: 741    
            StandAloneTransactionManager(BaseTransactionManager).init(TransactionServiceImp, Properties) line: 213    
            StandAloneTransactionManager.init(Properties) line: 95    
            UserTransactionServiceImp.init(TSInitInfo) line: 307    
            UserTransactionServiceImp.init(TSInitInfo) line: 411    
            UserTransactionManager.checkSetup() line: 89    
            UserTransactionManager.init() line: 139    
            NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]    
            NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39    
            DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25    
            Method.invoke(Object, Object...) line: 597    
            DefaultListableBeanFactory(AbstractAutowireCapableBeanFactory).invokeCustomInitMethod(String, Object, RootBeanDefinition) line: 1544    
            DefaultListableBeanFactory(AbstractAutowireCapableBeanFactory).invokeInitMethods(String, Object, RootBeanDefinition) line: 1485    
            DefaultListableBeanFactory(AbstractAutowireCapableBeanFactory).initializeBean(String, Object, RootBeanDefinition) line: 1417    
            DefaultListableBeanFactory(AbstractAutowireCapableBeanFactory).doCreateBean(String, RootBeanDefinition, Object[]) line: 519    
            DefaultListableBeanFactory(AbstractAutowireCapableBeanFactory).createBean(String, RootBeanDefinition, Object[]) line: 456    
            AbstractBeanFactory$1.getObject() line: 291    
            DefaultListableBeanFactory(DefaultSingletonBeanRegistry).getSingleton(String, ObjectFactory) line: 222    
            DefaultListableBeanFactory(AbstractBeanFactory).doGetBean(String, Class<T>, Object[], boolean) line: 288    
            DefaultListableBeanFactory(AbstractBeanFactory).getBean(String) line: 190    
            DefaultListableBeanFactory.preInstantiateSingletons() line: 580    
            ClassPathXmlApplicationContext(AbstractApplicationContext).finishBeanFactoryInitialization(ConfigurableListableBeanFactory) line: 895    
            ClassPathXmlApplicationContext(AbstractApplicationContext).refresh() line: 425    
            ClassPathXmlApplicationContext.<init>(String[], boolean, ApplicationContext) line: 139    
            ClassPathXmlApplicationContext.<init>(String) line: 83    
            TestMain.main(String[]) line: 39    
        Daemon Thread [Atomikos:0] (Running)    

The final connection is not created through my connection factory class so I don't know what's creating that but it may have something to do with Spring so that's outside the scope of this forum.

My initial concern is the extra connection created by Atomikos which I would like to find out why it does this.  I had a quick look at the code and it looks as if the transaction recovery service uses a transaction resource which doesn't used the Atomikos pooled connection factory but is using my connection factory directly.

Anybody seen this behaviour ?
Wayne Griffiths Send private email
Wednesday, February 01, 2012
 
 
Recovery requires one extra connection. Is that a problem?
Guy Pardon Send private email
Monday, February 06, 2012
 
 
No that's fine.  Just wanted to check what is was for.
Wayne Griffiths Send private email
Sunday, February 12, 2012
 
 

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

Other recent topics Other recent topics