Skip to content

Commit

Permalink
AbstractMessageListenerContainer calls "Session.recover()" in case of…
Browse files Browse the repository at this point in the history
… rollback attempt on non-transacted Session

Issue: SPR-12015
(cherry picked from commit c082220)
  • Loading branch information
jhoeller committed Jul 24, 2014
1 parent abd5f18 commit 7af1e00
Showing 1 changed file with 19 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -588,9 +588,14 @@ else if (message != null && isClientAcknowledge(session)) {
* @throws javax.jms.JMSException in case of a rollback error
*/
protected void rollbackIfNecessary(Session session) throws JMSException {
if (session.getTransacted() && isSessionLocallyTransacted(session)) {
// Transacted session created by this container -> rollback.
JmsUtils.rollbackIfNecessary(session);
if (session.getTransacted()) {
if (isSessionLocallyTransacted(session)) {
// Transacted session created by this container -> rollback.
JmsUtils.rollbackIfNecessary(session);
}
}
else {
session.recover();
}
}

Expand All @@ -602,12 +607,17 @@ protected void rollbackIfNecessary(Session session) throws JMSException {
*/
protected void rollbackOnExceptionIfNecessary(Session session, Throwable ex) throws JMSException {
try {
if (session.getTransacted() && isSessionLocallyTransacted(session)) {
// Transacted session created by this container -> rollback.
if (logger.isDebugEnabled()) {
logger.debug("Initiating transaction rollback on application exception", ex);
if (session.getTransacted()) {
if (isSessionLocallyTransacted(session)) {
// Transacted session created by this container -> rollback.
if (logger.isDebugEnabled()) {
logger.debug("Initiating transaction rollback on application exception", ex);
}
JmsUtils.rollbackIfNecessary(session);
}
JmsUtils.rollbackIfNecessary(session);
}
else {
session.recover();
}
}
catch (IllegalStateException ex2) {
Expand Down

0 comments on commit 7af1e00

Please sign in to comment.