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 Problem with Outbound JMS with Jencks XA Transactions
Date Wed, 22 Nov 2006 10:36:13 GMT

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#a7488527
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Mime
View raw message