Blame | Last modification | View Log | RSS feed
package com.smartdukaan.cron.scheduled;import com.spice.profitmandi.service.mail.MailOutboxService;import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.beans.factory.annotation.Value;import org.springframework.scheduling.annotation.Scheduled;import org.springframework.stereotype.Component;@Componentpublic class MailOutboxScheduler {private static final Logger LOGGER = LogManager.getLogger(MailOutboxScheduler.class);@Value("${prod:false}")private boolean isProd;@Autowiredprivate MailOutboxService mailOutboxService;@Scheduled(cron = "0 */2 * * * *")public void processPendingMails() {if (!isProd) {return;}try {mailOutboxService.processPendingMails();} catch (Exception e) {LOGGER.error("Error processing pending mails", e);}}@Scheduled(cron = "0 0 3 * * *")public void cleanupOldMails() {if (!isProd) {return;}try {mailOutboxService.cleanupOldMails(30);} catch (Exception e) {LOGGER.error("Error cleaning up old mails", e);}}}