try {
logger.info("Running ProcessAlertEvaluationQueue");
String accountName = dbPlugin.getAlertEvaluationQueueDao().getNextAccountToEvaluateAndMarkAsEvaluating();
while (accountName != null) {
logger.info("Processing alerts for account " + accountName);
BasicAccount account = new BasicAccount(dbPlugin.getAccountDao().getAccount(accountName));
account.setLastEvaluatedForAlerts(System.currentTimeMillis());
dbPlugin.getAccountDao().persistAccount(account);
//Get alerts for account
for (Alert alert : dbPlugin.getAlertDao().getAlerts(accountName)) {
logger.info("Evaluating alert: " + alert.getAlertName() + " for account: " + alert.getAccountName());
if (alert.isActivated()) {
AlertStatus oldStatus = alert.getStatus();
List<LiveStatistics> statList = getStatistic(alert.getGuiPath(), alert.getAlertDelay(), account.getId());
//Get statistics and evaluate alert condition
AlertStatus newStatus = evaluateStatistics(alert, statList);
if (oldStatus != newStatus && statList.size() >= 1) {
//Status have changed, store new triggeredAlert and send email
logger.info("Alert status changed: " + newStatus.getStatusName() + " num plugins: " + alert.getSelectedEmailSenderList().size());