-
Notifications
You must be signed in to change notification settings - Fork 38k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JmsTemplate/CachingConnectionFactory doesn't reset sessions if the underlying connection was physically closed [SPR-17499] #22031
Comments
Juergen Hoeller commented This is a general issue with JMS resources: We can't easily inspect whether they're actually still open. In the case of a listener, we simply abort the receive attempt, propagate the exception (leading to a connection reset) and wait for the message to arrive again. In the case of a producer, we'd have to implicitly retry the send which is not trivial to do at this level (we'd have to react to specific state exceptions at specific times in order to not retry unnecessarily). If there was an |
Kevin Möchel commented Sorry it took me so long to get back to this issue. Unfortunately neither |
Hi Juergen Hoeller, The issue of "org.springframework.jms.IllegalStateException: JMSCC0020 This session is closed." is occurring only intermittently Spring JMS version is 5.2.7 there was an exception when it tried to close the connection: so, the connection was not closed and in the retry of sending message closed session was used and failed again. Could you please help on this Thanks |
Kevin Möchel opened SPR-17499 and commented
If one uses the JmsTemplate to produce messages together with the CachingConnectionFactory it's possible to break the cached Sessions in a way that the application doesn't recover from this by itself, leaving no other options then to restart the application.
We use Oracle UCP and Oracle AQ for messaging. I think the problem cam occur with every JMS implementation though.
This is the exception we observe:
How to reproduce the error
Application Configuration
Configuration of the connection pool:
For arguments sake I set the abandonedConnectionTimeout, maxConnectionReuseTime and timeoutCheckInterval to 3, in order to force the ConnectionPool to close all connections that haven't been used for a little while.
XML-Configuration of the CachingConnectionFactory and the JmsTemplate:
Implementation of OracleAqConnectionFactoryBean:
.h3 Test
The first call of convertAndSend works as expected. However the second call will fail with the exception at the beginning.
It's possible to get the test above to run successfully if you call CachingConnectionFactory#resetConnection after the sleep.
Spring-JMS will call CachingConnectionFactory#resetConnection on its own given any JmsException, but only for Message-Consumer. I couldn't find similar behaviour for Message-Producer.
Is this something that should be adressed by Spring? The easiest fix is probably to reset the connections in the JmsTemplate if a JmsException occurs.
Affects: 4.3.19
The text was updated successfully, but these errors were encountered: