mirror of https://github.com/apache/activemq.git
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:
parent
d4a834743f
commit
4f715a2f8a
|
@ -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();
|
||||
|
|
|
@ -148,7 +148,6 @@ public class JDBCPersistenceAdapter extends DataSourceSupport implements Persist
|
|||
}
|
||||
|
||||
public void start() throws Exception {
|
||||
|
||||
getAdapter().setUseExternalMessageReferences(isUseExternalMessageReferences());
|
||||
|
||||
TransactionContext transactionContext = getTransactionContext();
|
||||
|
|
Loading…
Reference in New Issue