Atomikos Forum |
|
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
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
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
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 |