AspirinInternal.getLogger().info("Maintenance thread goes down.");
}
// Maintain queues in every hour
try {
QueueStore queueStore = AspirinInternal.getConfiguration().getQueueStore();
MailStore mailStore = AspirinInternal.getConfiguration().getMailStore();
List<String> usedMailIds = queueStore.clean();
List<String> mailStoreMailIds = mailStore.getMailIds();
AspirinInternal.getLogger().debug("Maintenance running: usedMailIds: {}, mailStoreMailIds: {}.",new Object[]{usedMailIds.size(), mailStoreMailIds.size()});
if( mailStoreMailIds.removeAll(usedMailIds) )
{
for( String unusedMailId : mailStoreMailIds )
mailStore.remove(unusedMailId);
}
} catch (Exception e) {
AspirinInternal.getLogger().error("Maintenance failed.",e);
}
}