activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Juergen Mayrbaeurl <juergen.mayrbae...@hvb.sozvers.at>
Subject Re: Problem with Outbound JMS with Jencks XA Transactions
Date Thu, 23 Nov 2006 09:48:32 GMT

It seems that I've found the problem. The solution is changing the
transaction support to use thread caching. The connection manager
configuration must look like:

	<!-- Jencks Connection Manager -->
	<bean id="connectionManager"
		class="org.jencks.factory.ConnectionManagerFactoryBean">
		<property name="transactionSupport">
			<bean class="org.jencks.factory.XATransactionFactoryBean">
				<property name="useTransactionCaching" value="true" />
				<property name="useThreadCaching" value="true" />
			</bean>
		</property>
		<property name="poolingSupport">
			<bean class="org.jencks.factory.SinglePoolFactoryBean">
				<property name="maxSize" value="2" />
				<property name="minSize" value="1" />
				<property name="blockingTimeoutMilliseconds" value="60" />
				<property name="idleTimeoutMinutes" value="60" />
				<property name="matchOne" value="true" />
				<property name="matchAll" value="true" />
				<property name="selectOneAssumeMatch" value="true" />
			</bean>
		</property>
		
		<property name="connectionTracker" ref="connectionTracker"/>
	</bean>

Notice the property 'useThreadCaching' in the bean class
'org.jencks.factory.XATransactionFactoryBean'. In my original configuration
the property was set to 'false'. After changing it to 'true' everything
worked correctly.

Can any of the ActiveMQ experts please confirm the configuration?

Kind regards
Juergen



Juergen Mayrbaeurl wrote:
> 
> Logging output to show the problem:
> 
> Created MBeanServer with ID: 1f1ad4a:10f0fa38af5:-8000:hvb0396:1
> RMIConnectorServer started at:
> service:jmx:rmi://localhost/jndi/rmi://localhost:1098/zpvverst
> 2006-11-22 13:28:34,866 [main] DEBUG
> org.springframework.transaction.interceptor.NameMatchTransactionAttributeSource
> - Adding transactional method [durchfuehrenFuerEmpfaengerDerMeldeneStelle]
> with attribute [PROPAGATION_REQUIRED,ISOLATION_DEFAULT]
> 2006-11-22 13:28:36,132 [main] DEBUG
> org.springframework.transaction.interceptor.NameMatchTransactionAttributeSource
> - Adding transactional method [versenden] with attribute
> [PROPAGATION_REQUIRED,ISOLATION_DEFAULT]
> 2006-11-22 13:28:36,897 [main] DEBUG
> org.springframework.transaction.interceptor.TransactionInterceptor -
> Getting transaction for
> at.sozvers.stp.zpv.bc.verstaend.IVerstaendigungskuvertSender.versenden
> 2006-11-22 13:28:37,772 [main] DEBUG
> org.springframework.transaction.interceptor.TransactionInterceptor -
> Invoking commit for transaction on
> at.sozvers.stp.zpv.bc.verstaend.IVerstaendigungskuvertSender.versenden
> 2006-11-22 13:28:37,882 [main] DEBUG
> org.springframework.transaction.interceptor.TransactionInterceptor -
> Getting transaction for
> at.sozvers.stp.zpv.bc.verstaend.IVerstaendigungskuvertSender.versenden
> 2006-11-22 13:28:38,100 [main] DEBUG
> org.springframework.transaction.interceptor.RuleBasedTransactionAttribute
> - Applying rules to determine whether transaction should rollback on
> java.lang.NullPointerException
> 2006-11-22 13:28:38,100 [main] DEBUG
> org.springframework.transaction.interceptor.RuleBasedTransactionAttribute
> - Winning rollback rule is: null
> 2006-11-22 13:28:38,116 [main] DEBUG
> org.springframework.transaction.interceptor.RuleBasedTransactionAttribute
> - No relevant rollback rule found: applying superclass default
> 2006-11-22 13:28:38,132 [main] DEBUG
> org.springframework.transaction.interceptor.TransactionInterceptor -
> Invoking rollback for transaction on
> at.sozvers.stp.zpv.bc.verstaend.IVerstaendigungskuvertSender.versenden due
> to throwable [java.lang.NullPointerException]
> 2006-11-22 13:28:38,132 [main] ERROR
> org.springframework.transaction.interceptor.TransactionInterceptor -
> Application exception overridden by rollback exception
> java.lang.NullPointerException
> 	at
> org.apache.activemq.ra.ManagedConnectionProxy.createSessionProxy(ManagedConnectionProxy.java:117)
> 	at
> org.apache.activemq.ra.ManagedConnectionProxy.createSession(ManagedConnectionProxy.java:106)
> 	at
> org.springframework.jms.core.JmsTemplate.createSession(JmsTemplate.java:771)
> 	at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:424)
> 	at org.springframework.jms.core.JmsTemplate.send(JmsTemplate.java:486)
> 	at
> at.sozvers.stp.zpv.verst.app.JMSKuvertSender.versenden(JMSKuvertSender.java:62)
> 	at
> at.sozvers.stp.zpv.verst.app.JMSKuvertSender.versenden(JMSKuvertSender.java:53)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> 	at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> 	at java.lang.reflect.Method.invoke(Method.java:324)
> 	at
> org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:287)
> 	at
> org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:181)
> 	at
> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:148)
> 	at
> org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
> 	at
> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
> 	at
> org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:176)
> 	at $Proxy16.versenden(Unknown Source)
> 	at
> at.sozvers.stp.zpv.verst.app.TestCaseKuvertSenden.testTXMehrfachVersand(TestCaseKuvertSenden.java:88)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> 	at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> 	at java.lang.reflect.Method.invoke(Method.java:324)
> 	at junit.framework.TestCase.runTest(TestCase.java:154)
> 	at junit.framework.TestCase.runBare(TestCase.java:127)
> 	at junit.framework.TestResult$1.protect(TestResult.java:106)
> 	at junit.framework.TestResult.runProtected(TestResult.java:124)
> 	at junit.framework.TestResult.run(TestResult.java:109)
> 	at junit.framework.TestCase.run(TestCase.java:118)
> 	at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
> 	at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
> 	at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
> 
> And a second one:
> 
> Created MBeanServer with ID: 16cf4f9:10f0f5aad90:-8000:hvb0396:1
> RMIConnectorServer started at:
> service:jmx:rmi://localhost/jndi/rmi://localhost:1098/zpvverst
> 2006-11-22 12:09:00,424 [main] DEBUG
> org.springframework.transaction.interceptor.NameMatchTransactionAttributeSource
> - Adding transactional method [durchfuehrenFuerEmpfaengerDerMeldeneStelle]
> with attribute [PROPAGATION_REQUIRED,ISOLATION_DEFAULT]
> 2006-11-22 12:09:00,799 [main] DEBUG
> org.springframework.transaction.interceptor.NameMatchTransactionAttributeSource
> - Adding transactional method [versenden] with attribute
> [PROPAGATION_REQUIRED,ISOLATION_DEFAULT]
> 2006-11-22 12:09:01,534 [main] DEBUG
> org.springframework.transaction.interceptor.TransactionInterceptor -
> Getting transaction for
> at.sozvers.stp.zpv.bc.verstaend.IVerstaendigungskuvertSender.versenden
> 2006-11-22 12:09:02,440 [main] DEBUG
> org.springframework.transaction.interceptor.TransactionInterceptor -
> Invoking commit for transaction on
> at.sozvers.stp.zpv.bc.verstaend.IVerstaendigungskuvertSender.versenden
> 2006-11-22 12:09:02,565 [main] DEBUG
> org.springframework.transaction.interceptor.TransactionInterceptor -
> Getting transaction for
> at.sozvers.stp.zpv.bc.verstaend.IVerstaendigungskuvertSender.versenden
> 2006-11-22 12:09:02,877 [main] DEBUG
> org.springframework.transaction.interceptor.RuleBasedTransactionAttribute
> - Applying rules to determine whether transaction should rollback on
> org.springframework.jms.IllegalStateException: The Session is closed;
> nested exception is javax.jms.IllegalStateException: The Session is closed
> 2006-11-22 12:09:02,877 [main] DEBUG
> org.springframework.transaction.interceptor.RuleBasedTransactionAttribute
> - Winning rollback rule is: null
> 2006-11-22 12:09:02,893 [main] DEBUG
> org.springframework.transaction.interceptor.RuleBasedTransactionAttribute
> - No relevant rollback rule found: applying superclass default
> 2006-11-22 12:09:02,893 [main] DEBUG
> org.springframework.transaction.interceptor.TransactionInterceptor -
> Invoking rollback for transaction on
> at.sozvers.stp.zpv.bc.verstaend.IVerstaendigungskuvertSender.versenden due
> to throwable [org.springframework.jms.IllegalStateException: The Session
> is closed; nested exception is javax.jms.IllegalStateException: The
> Session is closed]
> 2006-11-22 12:09:02,893 [main] ERROR
> org.springframework.transaction.interceptor.TransactionInterceptor -
> Application exception overridden by rollback exception
> org.springframework.jms.IllegalStateException: The Session is closed;
> nested exception is javax.jms.IllegalStateException: The Session is closed
> javax.jms.IllegalStateException: The Session is closed
> 	at
> org.apache.activemq.ra.ManagedSessionProxy.getSession(ManagedSessionProxy.java:93)
> 	at
> org.apache.activemq.ra.ManagedSessionProxy.createTextMessage(ManagedSessionProxy.java:275)
> 	at
> at.sozvers.stp.zpv.verst.app.JMSKuvertSender$1.createMessage(JMSKuvertSender.java:66)
> 	at org.springframework.jms.core.JmsTemplate.doSend(JmsTemplate.java:500)
> 	at
> org.springframework.jms.core.JmsTemplate$3.doInJms(JmsTemplate.java:489)
> 	at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:432)
> 	at org.springframework.jms.core.JmsTemplate.send(JmsTemplate.java:486)
> 	at
> at.sozvers.stp.zpv.verst.app.JMSKuvertSender.versenden(JMSKuvertSender.java:62)
> 	at
> at.sozvers.stp.zpv.verst.app.JMSKuvertSender.versenden(JMSKuvertSender.java:53)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> 	at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> 	at java.lang.reflect.Method.invoke(Method.java:324)
> 	at
> org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:287)
> 	at
> org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:181)
> 	at
> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:148)
> 	at
> org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
> 	at
> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
> 	at
> org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:176)
> 	at $Proxy16.versenden(Unknown Source)
> 	at
> at.sozvers.stp.zpv.verst.app.TestCaseKuvertSenden.testTXMehrfachVersand(TestCaseKuvertSenden.java:88)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> 	at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> 	at java.lang.reflect.Method.invoke(Method.java:324)
> 	at junit.framework.TestCase.runTest(TestCase.java:154)
> 	at junit.framework.TestCase.runBare(TestCase.java:127)
> 	at junit.framework.TestResult$1.protect(TestResult.java:106)
> 	at junit.framework.TestResult.runProtected(TestResult.java:124)
> 	at junit.framework.TestResult.run(TestResult.java:109)
> 	at junit.framework.TestCase.run(TestCase.java:118)
> 	at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
> 	at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
> 	at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
> 
> Kind regards
> Juergen
> 
> 
> Juergen Mayrbaeurl wrote:
>> 
>> We're having problems with Outbound JMS in our application.
>> 
>> The application is a Spring based Java native application that uses
>> Quartz to fire triggered jobs that are sending JMS messages to an
>> ActiveMQ message broker and writing to an Oracle Database with Hibernate
>> in one transaction. Each job is executing the transaction several times.
>> Jobs get triggered by Quartz in non concurrent mode.
>> 
>> Components used: JDK 1.4.2, Spring 1.2.8, Quartz 1.5, Hibernate 3.2 and
>> Jencks 1.3.
>> 
>> Unfortunately only the first transaction of a job (sending JMS message
>> and writting to the database) works correctly. The second transaction of
>> the job (executed in the same thread generated by Quartz) fails in method
>> execute()  of the JMSTemplate class with NPE, because the returned
>> ManagedConnectionProxy instance from method createConnection() has a NULL
>> value for the attribute 'managedConnection'.
>> 
>> Springs transaction demarcation is used with the
>> TransactionProxyFactoryBean class. We're using the JMSTemplate method
>> send(String, MessageCreator) for sending the message to the ActiveMQ
>> message broker (not embedded).
>> 
>> We tested sending multiple JMS messages without transactions and the same
>> setup (see below), too. This works fine. Therefore the problem must come
>> from the transaction handling.
>> 
>> Configuration setup looks like:
>> 
>> 	<!-- 
>> 		#### Transaction Manager ####
>> 	 -->
>> 	
>> 	<bean id="transactionContextManager" 
>> 		class="org.jencks.factory.TransactionContextManagerFactoryBean" 
>> 		abstract="false" singleton="true" lazy-init="default" 
>> 		autowire="default" dependency-check="default" /> 
>> 		
>>   	<bean id="userTransaction" 
>>   		class="org.jencks.factory.GeronimoTransactionManagerFactoryBean" 
>>   		abstract="false" singleton="true" lazy-init="default" 
>>   		autowire="default" dependency-check="default" /> 
>>   		
>> 	<bean id="transactionManager" 
>> 		class="org.springframework.transaction.jta.JtaTransactionManager" 
>> 		abstract="false" singleton="true" lazy-init="default" 
>> 		autowire="default" dependency-check="default">
>>  		<property name="userTransaction" ref="userTransaction" /> 
>>   	</bean>
>>   	
>>   	<!-- Enhydra JDBC Connection -->
>>     <bean id="verstDataSource" 
>>     	class="org.enhydra.jdbc.pool.StandardXAPoolDataSource" 
>>     		destroy-method="shutdown">
>>     		
>>         <property name="dataSource">
>>             <bean class="org.enhydra.jdbc.standard.StandardXADataSource" 
>>             	destroy-method="shutdown">
>>                 
>>                 <property name="transactionManager" ref="userTransaction"
>> />
>>                 <property name="driverName"
>> value="oracle.jdbc.driver.OracleDriver" />
>>                 <property name="url" 
>>                 	value="${verst.db.url}" />
>>             </bean>
>>         </property>
>>         <property name="user" value="${verst.db.username}"/>
>>         <property name="password" value="${verst.db.password}"/>
>>     </bean>
>> 
>> 	<bean id="connectionTracker" 
>> 	
>> class="org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTrackingCoordinator"/>
>> 
>> 	<!-- Jencks Connection Manager -->
>> 	<bean id="connectionManager"
>> 		class="org.jencks.factory.ConnectionManagerFactoryBean">
>> 		<property name="transactionSupport">
>> 			<bean class="org.jencks.factory.XATransactionFactoryBean">
>> 				<property name="useTransactionCaching" value="true" />
>> 				<property name="useThreadCaching" value="false" />
>> 			</bean>
>> 		</property>
>> 		<property name="poolingSupport">
>> 			<bean class="org.jencks.factory.SinglePoolFactoryBean">
>> 				<property name="maxSize" value="2" />
>> 				<property name="minSize" value="1" />
>> 				<property name="blockingTimeoutMilliseconds" value="60" />
>> 				<property name="idleTimeoutMinutes" value="60" />
>> 				<property name="matchOne" value="true" />
>> 				<property name="matchAll" value="true" />
>> 				<property name="selectOneAssumeMatch" value="true" />
>> 			</bean>
>> 		</property>
>> 		
>> 		<property name="connectionTracker" ref="connectionTracker"/>
>> 	</bean>
>> 
>> 	<!-- ActiveMQ Connection -->
>> 	<bean id="jmsResourceAdapter"
>> 		class="org.apache.activemq.ra.ActiveMQResourceAdapter">
>> 		<property name="serverUrl">
>> 			<value>${verst.mq.serverUrl}</value>
>> 		</property>
>> 	</bean>
>> 	<bean id="jmsManagedConnectionFactory"
>> 		class="org.apache.activemq.ra.ActiveMQManagedConnectionFactory">
>> 		<property name="resourceAdapter" ref="jmsResourceAdapter" />
>> 	</bean>
>> 	<bean id="jmsConnectionFactory"
>> 		class="org.springframework.jca.support.LocalConnectionFactoryBean">
>> 		<property name="managedConnectionFactory"
>> 			ref="jmsManagedConnectionFactory" />
>> 		<property name="connectionManager" ref="connectionManager" />
>> 	</bean>
>> 
>> 	<bean id="jencksJCAContainer" class="org.jencks.JCAContainer">
>>         <property name="bootstrapContext">
>>             <bean class="org.jencks.factory.BootstrapContextFactoryBean">
>>                 <property name="threadPoolSize" value="25"/>
>>             </bean>
>>         </property>
>>         <property name="resourceAdapter" ref="jmsResourceAdapter"/>
>>     </bean>
>> 
>> 	<!-- Transactional proxy fuer den Lauf -->
>> 	<bean id="txStdVerstaendigungslauf" 
>> 	
>> class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
>> 
>> 		<property name="transactionManager">
>> 			<ref bean="transactionManager"/>
>> 		</property>
>> 		
>> 		<property name="proxyInterfaces">
>> 		
>> <value>at.sozvers.stp.zpv.bc.verstaend.impl.schedule.IVerstaendigungslauf</value>
>> 		</property>
>> 
>> 		<property name="target">
>> 			<ref local="appVerstaendigungslauf"/>
>> 		</property>
>> 		
>> 		<property name="transactionAttributes">
>> 			<props>
>> 				<prop key="durchfuehrenFuerEmpfaengerDerMeldeneStelle">
>> 					PROPAGATION_REQUIRED
>> 				</prop>
>> 			</props>
>> 		</property>
>> 		
>> 		<property name="preInterceptors">
>> 			<list>
>> 				<ref bean="einHibernateInterceptor"/>
>> 			</list>
>> 		</property>
>> 		
>> 	</bean>
>> 
>> Kind regards
>> Juergen
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Problem-with-Outbound-JMS-with-Jencks-XA-Transactions-tf2684706.html#a7504042
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Mime
View raw message