cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ashaki...@apache.org
Subject cxf git commit: [CXF-6425]: Reverted processing of external transactions, throwing exception by detection, ensure closing the opened transactions
Date Thu, 28 May 2015 12:49:35 GMT
Repository: cxf
Updated Branches:
  refs/heads/master aa5ef9fc7 -> c750e5445


[CXF-6425]: Reverted processing of external transactions, throwing exception by detection,
ensure closing the opened transactions


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/c750e544
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/c750e544
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/c750e544

Branch: refs/heads/master
Commit: c750e54452bfa4cb9b0db018dad135b298847095
Parents: aa5ef9f
Author: Andrei Shakirin <andrei.shakirin@gmail.com>
Authored: Thu May 28 14:47:38 2015 +0200
Committer: Andrei Shakirin <andrei.shakirin@gmail.com>
Committed: Thu May 28 14:47:38 2015 +0200

----------------------------------------------------------------------
 .../util/PollingMessageListenerContainer.java   | 26 +++++++++-----------
 1 file changed, 12 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/c750e544/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/util/PollingMessageListenerContainer.java
----------------------------------------------------------------------
diff --git a/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/util/PollingMessageListenerContainer.java
b/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/util/PollingMessageListenerContainer.java
index 37d0080..f79ab09 100644
--- a/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/util/PollingMessageListenerContainer.java
+++ b/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/util/PollingMessageListenerContainer.java
@@ -32,6 +32,8 @@ import javax.jms.MessageConsumer;
 import javax.jms.MessageListener;
 import javax.jms.Session;
 import javax.jms.Topic;
+import javax.transaction.Status;
+import javax.transaction.Transaction;
 
 import org.apache.cxf.common.logging.LogUtils;
 
@@ -104,10 +106,12 @@ public class PollingMessageListenerContainer extends AbstractMessageListenerCont
                 MessageConsumer consumer = null;
                 Session session = null;
                 try {
-                    boolean isExternalTransaction = transactionManager.getTransaction() !=
null;
-                    if (!isExternalTransaction) {
-                        transactionManager.begin();
+                    final Transaction externalTransaction = transactionManager.getTransaction();
+                    if ((externalTransaction != null) && (externalTransaction.getStatus()
== Status.STATUS_ACTIVE)) {
+                        LOG.log(Level.SEVERE, "External transactions are not supported in
XAPoller");
+                        throw new IllegalStateException("External transactions are not supported
in XAPoller");
                     }
+                    transactionManager.begin();
                     /*
                      * Create session inside transaction to give it the 
                      * chance to enlist itself as a resource
@@ -119,12 +123,10 @@ public class PollingMessageListenerContainer extends AbstractMessageListenerCont
                         if (message != null) {
                             listenerHandler.onMessage(message);
                         }
-                        if (!isExternalTransaction) {
-                            transactionManager.commit();
-                        }
-                    } catch (Exception e) {
+                        transactionManager.commit();
+                    } catch (Throwable e) {
                         LOG.log(Level.WARNING, "Exception while processing jms message in
cxf. Rolling back", e);
-                        safeRollBack(session, isExternalTransaction);
+                        safeRollBack(session);
                     } finally {
                         ResourceCloser.close(consumer);
                         ResourceCloser.close(session);
@@ -137,13 +139,9 @@ public class PollingMessageListenerContainer extends AbstractMessageListenerCont
 
         }
         
-        private void safeRollBack(Session session, boolean isExternalTransaction) {
+        private void safeRollBack(Session session) {
             try {
-                if (isExternalTransaction) {
-                    transactionManager.setRollbackOnly();
-                } else {
-                    transactionManager.rollback();
-                }
+                transactionManager.rollback();
             } catch (Exception e) {
                 LOG.log(Level.WARNING, "Rollback of XA transaction failed", e);
             }


Mime
View raw message