11/*
2- * Copyright 2002-2012 the original author or authors.
2+ * Copyright 2002-2014 the original author or authors.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
@@ -588,9 +588,14 @@ else if (message != null && isClientAcknowledge(session)) {
588588 * @throws javax.jms.JMSException in case of a rollback error
589589 */
590590 protected void rollbackIfNecessary (Session session ) throws JMSException {
591- if (session .getTransacted () && isSessionLocallyTransacted (session )) {
592- // Transacted session created by this container -> rollback.
593- JmsUtils .rollbackIfNecessary (session );
591+ if (session .getTransacted ()) {
592+ if (isSessionLocallyTransacted (session )) {
593+ // Transacted session created by this container -> rollback.
594+ JmsUtils .rollbackIfNecessary (session );
595+ }
596+ }
597+ else {
598+ session .recover ();
594599 }
595600 }
596601
@@ -602,12 +607,17 @@ protected void rollbackIfNecessary(Session session) throws JMSException {
602607 */
603608 protected void rollbackOnExceptionIfNecessary (Session session , Throwable ex ) throws JMSException {
604609 try {
605- if (session .getTransacted () && isSessionLocallyTransacted (session )) {
606- // Transacted session created by this container -> rollback.
607- if (logger .isDebugEnabled ()) {
608- logger .debug ("Initiating transaction rollback on application exception" , ex );
610+ if (session .getTransacted ()) {
611+ if (isSessionLocallyTransacted (session )) {
612+ // Transacted session created by this container -> rollback.
613+ if (logger .isDebugEnabled ()) {
614+ logger .debug ("Initiating transaction rollback on application exception" , ex );
615+ }
616+ JmsUtils .rollbackIfNecessary (session );
609617 }
610- JmsUtils .rollbackIfNecessary (session );
618+ }
619+ else {
620+ session .recover ();
611621 }
612622 }
613623 catch (IllegalStateException ex2 ) {
0 commit comments