Announcement Announcement Module
No announcement yet.
JmsTemplate participating in transactions when it shouldn't Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • JmsTemplate participating in transactions when it shouldn't


    I've got a the following problem:

    1. a call to a service, this service uses hibernate dao which is JTA transacted
    2. this dao throws a RuntimeException due to a duplicate key - and the dao is rolled back - fine
    3. inside of this a jmstemplate is supposed to send a message (because we've noticed the duplicate key - so we want to send an event).

    So 3 is inside a JTA transaction - but SHOULD NOT participate in it, which it still seems to do.

    The queue connection factory is set up to NOT use XA, and thus I expect it to not participate with them either.

    The env:
    was 6.1
    spring 2.0.7

    Spring logging:

    05/11 16:49:59,124 [WebContainer : 0] DEBUG org.springframework.transaction.jta.JtaTransaction Manager - Triggering beforeCompletion synchronization
    05/11 16:49:59,124 [WebContainer : 0] DEBUG nSynchronizationManager - Removed value [[email protected] 7307730] for key [[email protected]] from thread [WebContainer : 0]
    05/11 16:49:59,124 [WebContainer : 0] DEBUG nSynchronizationManager - Removed value [org.springframework.jms.connection.JmsResourceHold [email protected]] for key [[email protected] 1e341e
    managed connection factory = @7af87af8
    connection manager = [email protected]
    restricted methods enabled = false] from thread [WebContainer : 0]
    05/11 16:49:59,140 [WebContainer : 0] DEBUG org.springframework.transaction.jta.JtaTransaction Manager - Initiating transaction rollback

  • #2
    A JmsTransactionManager can help


    Maybe this can help:

    Just use the JmsTransactionManager (for your connection, if not already configured) and TX-annotations or an tx:advice if TX-annotations are already bound to the database TX-manager:

        <bean id="jmsTransactionManager"
            <property name="connectionFactory" ref="connectionFactory"/>
        <tx:annotation-driven transaction-manager="jmsTransactionManager"/>
            <aop:pointcut id="entryPointMethod" expression="execution(* *. senderMethod*(..))"/>
        <tx:advice id="jmsTxAdvice" transaction-manager="jmsTransactionManager">
                <tx:method name="*" propagation="NOT_SUPPORTED"/>
    Send your message within an injected bean and if using the annotation style just annotate these sender methods:

        @Transactional(propagation = Propagation.NOT_SUPPORTED)
        public ... send(...) {
    Hope this helps.

    Bye, Torsten