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

  • Jms jta requires_new

    Hello,

    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

    Code:
    <jee:jndi-lookup id="entityManagerFactory" jndi-name="persistence/xxx"/>
    <jee:jndi-lookup id="connectionFactory" jndi-name="jms/xxxConnectionFactory"/>
    <tx:jta-transaction-manager/>
    
        <aop:config >
            <aop:pointcut id="defaultFacadeOperation" 
                        expression="xxx>
            <aop:advisor pointcut-ref="defaultFacadeOperation" advice-ref="defaultTxAdvice" order="200"/>
        </aop:config>
    
        <tx:advice id="defaultTxAdvice" transaction-manager="transactionManager">
            <tx:attributes>
                <tx:method name="*" propagation="REQUIRES_NEW" />
            </tx:attributes>
        </tx:advice>
    <aop:config>
    		<aop:pointcut id="commObject"
    			expression="yyy" />
    		<aop:advisor pointcut-ref="commObject" advice-ref="jmsOutboundTxAdvice"
    			order="200" />
    	</aop:config>
    
    	<tx:advice id="jmsOutboundTxAdvice" transaction-manager="transactionManager">
    		<tx:attributes>
    			<tx:method name="*Isolated" propagation="REQUIRES_NEW" />
    		</tx:attributes>
    	</tx:advice>
    
    		<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"/>
    		</jms:listener-container>
    
    		<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"/>
    		</bean>
    Any help is welcome.

    Regards,

    Tim
    Last edited by timpke; Aug 20th, 2009, 07: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.

    Comment

    Working...
    X