Atomikos Forum

transaction in com.atomikos.jms.extra.MessageDrivenContainer

Hello

I am using MessageDrivenContainer with the following config:

<bean id="messageDrivenContainer" class="com.atomikos.jms.extra.MessageDrivenContainer"
 init-method="start" destroy-method="stop" lazy-init="false">
        <property name="atomikosConnectionFactoryBean" ref="atomikosConnectionFactory" />
        <property name="transactionTimeout" value="120"/>
        <property name="destination" ref="queue" />
        <property name="messageListener" ref="MessageListener" />
        <property name="poolSize" value="1" />
        
    </bean>


I looked at the class org.springframework.jms.listener.DefaultMessageListenerContainer and it has a property where I can inject the transactionManager.  Where is the similar property in the MessageDrivenContainer? How do I make it a part of a transaction? 

thanks
sonam Send private email
Wednesday, April 28, 2010
 
 
Hi,

Our container starts a transaction always, no need to inject.

However, there are other reasons why injecting the TransactionManager would be good, so we have this on our backlog for a future release. Among other things, it would make shutdown more elegant...

HTH
Guy Pardon Send private email
Wednesday, April 28, 2010
 
 
So if we have a transaction manager using the following bean declarations:
     <!-- Construct Atomikos UserTransactionManager, needed to configure Spring -->
    <bean id="AtomikosTransactionManager" class="com.atomikos.icatch.jta.UserTransactionManager"
        init-method="init" destroy-method="close">
         <!-- 
        when close is called, should we force 
        transactions to terminate or not? 
          -->
        <property name="forceShutdown" value="true" />
    </bean>
     
      <!--  Also use Atomikos UserTransactionImp, needed to configure Spring  --> 
    <bean id="AtomikosUserTransaction" class="com.atomikos.icatch.jta.UserTransactionImp" >
        <property name="transactionTimeout" value="300" />
    </bean>
     
      <!-- Configure the Spring framework to use JTA transactions from Atomikos  -->
    <bean id="JtaTransactionManager" class="org.springframework.transaction.jta.JtaTransactionManager" >
        <property name="transactionManager" ref="AtomikosTransactionManager" />
        <property name="userTransaction" ref="AtomikosUserTransaction" />
    </bean>


Then how does the MessageDrivenContainer be part of that Atomikos transaction manager bean declarations that I have defined above? 

So is it correct that if an RuntimeException is thrown after the message is consumed using the MessageDrivenContainer, the message will be rolled back to the JMS queue/topic?

thanks
sonam Send private email
Wednesday, April 28, 2010
 
 
For message driven, you don't need any of the config you mention. The container does this.

A runtime error will put the message back on the queue, as per JMS/XA semantics.

HTH
Guy Pardon Send private email
Wednesday, April 28, 2010
 
 
Does MessageDrivenContainer do a automatic discovery of an existing transaction manager is one exists and start a new transaction manager if one does not exist? 

The reason I ask this question is because after my pojo has received the message through the MessageDrivenContainer I need to persist the data into a database.  Is there a way to reference the transactionManager so that I can inject the datasource  into the transactionManager to make it part of that XA transaction?

I want to do similar to the following:

  <!-- similarly, don't forget the PlatformTransactionManager -->
  <bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    <property name="dataSource" ref="dataSource"/>
  </bean>


thanks
sonam Send private email
Wednesday, April 28, 2010
 
 
Just use our datasource and you should be fine.

If you want to be sure, please consider buying "developer access" so we can review your configuration in detail.

Thanks
Guy Pardon Send private email
Thursday, April 29, 2010
 
 

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

Other recent topics Other recent topics