From 4f715a2f8ac98a79cfdfcafda55f2dc78b45c8cd Mon Sep 17 00:00:00 2001 From: James Strachan Date: Wed, 23 Aug 2006 10:55:55 +0000 Subject: [PATCH] Have just added a short circuit for the loop trying to acquire the exclusive lock so that we fail fast if we are stopping to fix AMQ-893 git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@434007 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/activemq/store/jdbc/DefaultDatabaseLocker.java | 6 ++++++ .../apache/activemq/store/jdbc/JDBCPersistenceAdapter.java | 1 - 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/activemq-core/src/main/java/org/apache/activemq/store/jdbc/DefaultDatabaseLocker.java b/activemq-core/src/main/java/org/apache/activemq/store/jdbc/DefaultDatabaseLocker.java index 5c3001e63f..145ff14402 100644 --- a/activemq-core/src/main/java/org/apache/activemq/store/jdbc/DefaultDatabaseLocker.java +++ b/activemq-core/src/main/java/org/apache/activemq/store/jdbc/DefaultDatabaseLocker.java @@ -40,6 +40,7 @@ public class DefaultDatabaseLocker implements DatabaseLocker { private final Statements statements; private long sleepTime = 1000; private Connection connection; + private boolean stopping; public DefaultDatabaseLocker(DataSource dataSource, Statements statements) { this.dataSource = dataSource; @@ -47,6 +48,7 @@ public class DefaultDatabaseLocker implements DatabaseLocker { } public void start() throws Exception { + stopping = false; connection = dataSource.getConnection(); connection.setAutoCommit(false); @@ -60,6 +62,9 @@ public class DefaultDatabaseLocker implements DatabaseLocker { } } catch (Exception e) { + if (stopping) { + throw new Exception("Cannot start broker as being asked to shut down. Interupted attempt to acquire lock: " + e, e); + } log.error("Failed to acquire lock: " + e, e); } log.debug("Sleeping for " + sleepTime + " milli(s) before trying again to get the lock..."); @@ -70,6 +75,7 @@ public class DefaultDatabaseLocker implements DatabaseLocker { } public void stop() throws Exception { + stopping = true; if (connection != null) { connection.rollback(); connection.close(); diff --git a/activemq-core/src/main/java/org/apache/activemq/store/jdbc/JDBCPersistenceAdapter.java b/activemq-core/src/main/java/org/apache/activemq/store/jdbc/JDBCPersistenceAdapter.java index 094d5a5c42..5667eedc6f 100755 --- a/activemq-core/src/main/java/org/apache/activemq/store/jdbc/JDBCPersistenceAdapter.java +++ b/activemq-core/src/main/java/org/apache/activemq/store/jdbc/JDBCPersistenceAdapter.java @@ -148,7 +148,6 @@ public class JDBCPersistenceAdapter extends DataSourceSupport implements Persist } public void start() throws Exception { - getAdapter().setUseExternalMessageReferences(isUseExternalMessageReferences()); TransactionContext transactionContext = getTransactionContext();