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
This commit is contained in:
James Strachan 2006-08-23 10:55:55 +00:00
parent d4a834743f
commit 4f715a2f8a
2 changed files with 6 additions and 1 deletions

View File

@ -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();

View File

@ -148,7 +148,6 @@ public class JDBCPersistenceAdapter extends DataSourceSupport implements Persist
}
public void start() throws Exception {
getAdapter().setUseExternalMessageReferences(isUseExternalMessageReferences());
TransactionContext transactionContext = getTransactionContext();