Commit 76439944 authored by Daniel Henninger's avatar Daniel Henninger Committed by dhenninger

[JM-1298] Added auto-retry when attempting to get a new DB connection.

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/branches@10092 b35dd754-fafc-0310-a699-88a17e54d16e
parent f4f061e6
...@@ -93,12 +93,32 @@ public class DbConnectionManager { ...@@ -93,12 +93,32 @@ public class DbConnectionManager {
} }
} }
} }
Connection con = connectionProvider.getConnection();
// TODO: May want to make these settings configurable
Integer retryCnt = 0;
Integer retryMax = 10;
Integer retryWait = 250; // milliseconds
Connection con;
do {
retryCnt++;
con = connectionProvider.getConnection();
if (con != null) {
// Got one, lets hand it off.
break;
}
try {
Thread.sleep(retryWait);
}
catch (Exception e) {
// Ignored
}
} while (retryCnt <= retryMax);
if (con == null) { if (con == null) {
Log.error("WARNING: ConnectionManager.getConnection() " + Log.error("WARNING: ConnectionManager.getConnection() " +
"failed to obtain a connection."); "failed to obtain a connection.");
} }
// See if profiling is enabled. If yes, wrap the connection with a // See if profiling is enabled. If yes, wrap the connection with a
// profiled connection. // profiled connection.
if (profilingEnabled) { if (profilingEnabled) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment