A problem has occures when using ActiveMq with Spring and a non-jms/non-jta transaction manager. The TransactionSynchronizationUtils will try to commit jms transactions in the invokeAfterCommit method. This method calls the JmsResourceHolder.commitAll(), which silently ignores all IllegalStateException with an inline comment suggesting that it should only happen in the event of a Jta transaction being active.
Looking at the javax.jms.Session javadoc it seems that this is not the case, it states: "Invoking any other Session method on a closed session must throw a JMSException.IllegalStateException. Closing a closed session must not throw an exception" see: http://download.oracle.com/docs/cd/E17477_01/javaee/1.4/api/javax/jms/Session.html#close
I first raised this issue with ActiveMq: http://issues.apache.org/activemq/browse/AMQ-2812 where Rob Davies pointed me to the relevant point in the jms javadoc stating that IllegalStateException should be thrown if any operation is done on a closed session.
We are experiencing this issue when the ActiveMq server is going down and not coming up before the commit is executed.
Referenced from: commits d1d5e2d
Juergen Hoeller commented
That's actually very old code, back from the original JmsTemplate days: Some providers seem to have thrown an IllegalStateException where they should have thrown a TransactionInProgressException, and we were just being defensive about that. I suppose this is not the case with modern providers anymore, 12 years after the JMS 1.0.2 specification clearly defined the use of TransactionInProgressException there. As a consequence, I removed the IllegalStateException catch clause from JmsResourceHolder without any further conditional checking.
This will be available in tonight's 3.0.4 snapshot. Feel free to give it an early try...