this.serviceLocator = serviceLocator;
this.interval = interval;
}
public void run() {
ResourceRecoveryManager recoveryManager = serviceLocator.getService(ResourceRecoveryManager.class);
if (interval <= 0) {
// Only start the recovery thread if the interval value is set, and set to a positive value
return;
}
if (_logger.isLoggable(Level.INFO)) {
_logger.log(Level.INFO,"Asynchronous thread for incomplete "
+ "tx is enabled with interval " + interval);
}
int prevSize = 0;
try {
while(true) {
Thread.sleep(interval*1000L);
if (!RecoveryManager.isIncompleteTxRecoveryRequired()) {
if (_logger.isLoggable(Level.FINE))
_logger.log(Level.FINE, "Incomplete transaction recovery is "
+ "not requeired, waiting for the next interval");
continue;
}
if (RecoveryManager.sizeOfInCompleteTx() <= prevSize) {
if (_logger.isLoggable(Level.FINE))
_logger.log(Level.FINE, "Incomplete transaction recovery is "
+ "not required, waiting for the next interval SIZE");
continue;
}
prevSize = RecoveryManager.sizeOfInCompleteTx();
recoveryManager.recoverIncompleteTx(false, null);
}
} catch (Exception ex) {
if (_logger.isLoggable(Level.FINE))
_logger.log(Level.FINE, " Exception occurred in recoverInCompleteTx ");
}