From b7c430d0683c8f682c5a88a063a8bbdda0ebdf07 Mon Sep 17 00:00:00 2001 From: gtully Date: Mon, 9 Dec 2013 17:01:56 +0000 Subject: [PATCH] https://issues.apache.org/jira/browse/AMQ-1063 - revert delayed change to inTx flag, now cleared before exception is thrown by getConnection, this ensures jms transactions can use autocommit=false --- .../org/apache/activemq/store/jdbc/TransactionContext.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/activemq-jdbc-store/src/main/java/org/apache/activemq/store/jdbc/TransactionContext.java b/activemq-jdbc-store/src/main/java/org/apache/activemq/store/jdbc/TransactionContext.java index 66163b6372..6a933b0840 100755 --- a/activemq-jdbc-store/src/main/java/org/apache/activemq/store/jdbc/TransactionContext.java +++ b/activemq-jdbc-store/src/main/java/org/apache/activemq/store/jdbc/TransactionContext.java @@ -38,7 +38,7 @@ public class TransactionContext { private final DataSource dataSource; private final JDBCPersistenceAdapter persistenceAdapter; private Connection connection; - private volatile boolean inTx; + private boolean inTx; private PreparedStatement addMessageStatement; private PreparedStatement removedMessageStatement; private PreparedStatement updateLastAckStatement; @@ -63,6 +63,8 @@ public class TransactionContext { } } catch (SQLException e) { JDBCPersistenceAdapter.log("Could not get JDBC connection: ", e); + inTx = false; + close(); IOException ioe = IOExceptionSupport.create(e); persistenceAdapter.getBrokerService().handleIOException(ioe); throw ioe; @@ -160,9 +162,8 @@ public class TransactionContext { if (inTx) { throw new IOException("Already started."); } - connection = getConnection(); - // only mark in tx if we could get a connection inTx = true; + connection = getConnection(); } public void commit() throws IOException {