|
|
|
@ -21,9 +21,8 @@ public class MailQueueServiceImpl implements MailQueueService{
|
|
|
|
|
@Autowired
|
|
|
|
|
MailDAO mailDAO;
|
|
|
|
|
|
|
|
|
|
// private volatile Thread
|
|
|
|
|
// processingThread;
|
|
|
|
|
// private volatile boolean isProcessingMails;
|
|
|
|
|
private volatile Thread processingThread;
|
|
|
|
|
private volatile boolean isProcessingMails;
|
|
|
|
|
// private final MailDAO mailDAO;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -58,22 +57,22 @@ public class MailQueueServiceImpl implements MailQueueService{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// public void clearOnServerShutdown(){
|
|
|
|
|
// BlockingQueue<MailModel> priorityQueue = PriorityQueueHolder.getInstance().getPriorityQueue();
|
|
|
|
|
// if (processingThread != null){
|
|
|
|
|
// while (isProcessingMails){
|
|
|
|
|
// try {
|
|
|
|
|
// Thread.sleep(1000);
|
|
|
|
|
// }catch (InterruptedException e){
|
|
|
|
|
// Thread.currentThread().interrupt();
|
|
|
|
|
// logger.info("Error waiting for the processing cycle to complete" + e.getMessage());
|
|
|
|
|
// }
|
|
|
|
|
// isProcessingMails = priorityQueue.peek() != null;
|
|
|
|
|
// }
|
|
|
|
|
// processingThread.interrupt();
|
|
|
|
|
// }
|
|
|
|
|
// logger.info("Server shutdown");
|
|
|
|
|
// }
|
|
|
|
|
public void clearOnServerShutdown(){
|
|
|
|
|
BlockingQueue<MailModel> priorityQueue = PriorityQueueHolder.getInstance().getPriorityQueue();
|
|
|
|
|
if (processingThread != null){
|
|
|
|
|
while (isProcessingMails){
|
|
|
|
|
try {
|
|
|
|
|
Thread.sleep(1000);
|
|
|
|
|
}catch (InterruptedException e){
|
|
|
|
|
Thread.currentThread().interrupt();
|
|
|
|
|
logger.info("Error waiting for the processing cycle to complete" + e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
isProcessingMails = priorityQueue.peek() != null;
|
|
|
|
|
}
|
|
|
|
|
processingThread.interrupt();
|
|
|
|
|
}
|
|
|
|
|
logger.info("Server shutdown");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|