Announcement Announcement Module
No announcement yet.
Jms jta requires_new Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Jms jta requires_new


    I'm using Spring 2.5.6
    Deploying on a WAS7 (IBM JVM 1.6).
    With a container managed persitence unit(hibernate).
    And a JMS connection factory using a Resource adaptor, non XA (for various reasons)

    What I want to do.
    A jms:listener-container receives a message (transtional).
    A database transaction is started (because of non XA).
    Inside this transaction a JMS message is send. The problem is that this JMS message should "never" be rolledbacked.

    I tried using REQUIRES_NEW, but that doesn't work unless I add the JmsTransactionManager. But when I add the JmsTransactionManager, the jms connections are never closed by Spring (atleast thats what I think) and the jms connection-pool runs out of connections.

    Here is some config

    <jee:jndi-lookup id="entityManagerFactory" jndi-name="persistence/xxx"/>
    <jee:jndi-lookup id="connectionFactory" jndi-name="jms/xxxConnectionFactory"/>
        <aop:config >
            <aop:pointcut id="defaultFacadeOperation" 
            <aop:advisor pointcut-ref="defaultFacadeOperation" advice-ref="defaultTxAdvice" order="200"/>
        <tx:advice id="defaultTxAdvice" transaction-manager="transactionManager">
                <tx:method name="*" propagation="REQUIRES_NEW" />
    		<aop:pointcut id="commObject"
    			expression="yyy" />
    		<aop:advisor pointcut-ref="commObject" advice-ref="jmsOutboundTxAdvice"
    			order="200" />
    	<tx:advice id="jmsOutboundTxAdvice" transaction-manager="transactionManager">
    			<tx:method name="*Isolated" propagation="REQUIRES_NEW" />
    		<jms:listener-container connection-factory="connectionFactory" concurrency="3" destination-resolver="destinationResolver" acknowledge="transacted"
    			 message-converter="messageConverter" task-executor="workManagerTaskExecutor" destination-type="queue">
    			<jms:listener destination="jms/xxxInboundQueue" ref="exposedMethodEndpointImpl" method="onMessage" selector="xxx"/>
    		<bean id="outboundJmsTemplate" class="org.springframework.jms.core.JmsTemplate">
    			<property name="connectionFactory" ref="connectionFactory"/>
    			<property name="destinationResolver" ref="destinationResolver"/>
    			<property name="defaultDestinationName" value="jms/xxxOutboundQueue"/>
    			<property name="messageConverter" ref="messageConverter"/>
    Any help is welcome.


    Last edited by timpke; Aug 20th, 2009, 06:30 AM. Reason: typo

  • #2
    After a number of tests I found to solutions:

    One working solution was to use 2 connectionFactories and remove the JmsTransaction manager.

    The other solution (the one I'm going to use) was to remove the
    connectionFactory from JNDI and use the CachingConnectionFactory.

    After all the test I think the problem was related to the GenericRa and not to Spring.