AbstractMessageListenerContainer calls "Session.recover()" in case of rollback attempt on non-transacted Session

Issue: SPR-12015
This commit is contained in:
Juergen Hoeller 2014-07-22 16:50:41 +02:00
parent 5e2fbe7355
commit c082220b34
1 changed files with 18 additions and 8 deletions

View File

@ -711,11 +711,16 @@ public abstract class AbstractMessageListenerContainer
* @throws javax.jms.JMSException in case of a rollback error * @throws javax.jms.JMSException in case of a rollback error
*/ */
protected void rollbackIfNecessary(Session session) throws JMSException { protected void rollbackIfNecessary(Session session) throws JMSException {
if (session.getTransacted() && isSessionLocallyTransacted(session)) { if (session.getTransacted()) {
if (isSessionLocallyTransacted(session)) {
// Transacted session created by this container -> rollback. // Transacted session created by this container -> rollback.
JmsUtils.rollbackIfNecessary(session); JmsUtils.rollbackIfNecessary(session);
} }
} }
else {
session.recover();
}
}
/** /**
* Perform a rollback, handling rollback exceptions properly. * Perform a rollback, handling rollback exceptions properly.
@ -725,7 +730,8 @@ public abstract class AbstractMessageListenerContainer
*/ */
protected void rollbackOnExceptionIfNecessary(Session session, Throwable ex) throws JMSException { protected void rollbackOnExceptionIfNecessary(Session session, Throwable ex) throws JMSException {
try { try {
if (session.getTransacted() && isSessionLocallyTransacted(session)) { if (session.getTransacted()) {
if (isSessionLocallyTransacted(session)) {
// Transacted session created by this container -> rollback. // Transacted session created by this container -> rollback.
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug("Initiating transaction rollback on application exception", ex); logger.debug("Initiating transaction rollback on application exception", ex);
@ -733,6 +739,10 @@ public abstract class AbstractMessageListenerContainer
JmsUtils.rollbackIfNecessary(session); JmsUtils.rollbackIfNecessary(session);
} }
} }
else {
session.recover();
}
}
catch (IllegalStateException ex2) { catch (IllegalStateException ex2) {
logger.debug("Could not roll back because Session already closed", ex2); logger.debug("Could not roll back because Session already closed", ex2);
} }