1
1
/*
2
- * Copyright 2002-2012 the original author or authors.
2
+ * Copyright 2002-2014 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -588,9 +588,14 @@ else if (message != null && isClientAcknowledge(session)) {
588
588
* @throws javax.jms.JMSException in case of a rollback error
589
589
*/
590
590
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 ();
594
599
}
595
600
}
596
601
@@ -602,12 +607,17 @@ protected void rollbackIfNecessary(Session session) throws JMSException {
602
607
*/
603
608
protected void rollbackOnExceptionIfNecessary (Session session , Throwable ex ) throws JMSException {
604
609
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 );
609
617
}
610
- JmsUtils .rollbackIfNecessary (session );
618
+ }
619
+ else {
620
+ session .recover ();
611
621
}
612
622
}
613
623
catch (IllegalStateException ex2 ) {
0 commit comments