Я столкнулся с проблемой в моем приложении весенней загрузки, когда все планировщики не запускаются, хотя я выделил достаточно потоков. Я также сделал этот метод getAllEmails asyn c
В журналах я не вижу ошибки только при запуске, некоторые планировщики будут работать, а другие - нет. Может ли кто-нибудь подсказать, как мне убедиться, что все мои планировщики работают в назначенные временные интервалы
Ниже мой код контроллера
@RestController
@EnableScheduling
@ConditionalOnProperty(value = "mailengine.incoming.scheduler.enabled", havingValue = "true")
public class IncomingEmailController {
private final Logger LOGGER = LoggerFactory.getLogger(IncomingEmailController.class);
@Autowired
private Environment env;
@Autowired
IncomingEmailService incomingEmailService;
private static final String IS_INCOMING_SCHEDULER_ENABLED="mailengine.incoming.scheduler.enabled";
// @Scheduled(fixedRateString="${mailbox.incoming.scheduler.time}",initialDelay= 1000)
@RequestMapping(value = "/getAllEmails", method = RequestMethod.GET)
public Boolean getAllEmails() throws Exception {
if(env.getProperty(IS_INCOMING_SCHEDULER_ENABLED) != null &&
"true".equalsIgnoreCase(env.getProperty(IS_INCOMING_SCHEDULER_ENABLED).toString())){
boolean status = false;
LOGGER.info("Starting scheduler..... getAllEmails 0");
status = incomingEmailService.getIncomingEmails(0);
LOGGER.info("Completed scheduler..... getAllEmails 0");
return status;
} else {
LOGGER.info("getAllEmails 0 scheduler is disabled");
return false;
}
}
/* @Scheduled(fixedRateString = "${mailbox.incoming.scheduler.time}", initialDelay = 1000)*/
@Scheduled(cron="${mailbox.incoming.scheduler.time1}")
@RequestMapping(value = "/getAllEmails1", method = RequestMethod.GET)
public Boolean getAllEmails1() throws Exception {
if(env.getProperty(IS_INCOMING_SCHEDULER_ENABLED) != null &&
"true".equalsIgnoreCase(env.getProperty(IS_INCOMING_SCHEDULER_ENABLED).toString())){
boolean status = false;
LOGGER.info("Starting scheduler..... getAllEmails 1");
status = incomingEmailService.getIncomingEmails(1);
LOGGER.info("Completed scheduler..... getAllEmails 1");
return status;
} else {
LOGGER.info("getAllEmails 1 scheduler is disabled");
return false;
}
}
@Scheduled(cron="${mailbox.incoming.scheduler.time2}")
@RequestMapping(value = "/getAllEmails2", method = RequestMethod.GET)
public Boolean getAllEmails2() throws Exception {
if(env.getProperty(IS_INCOMING_SCHEDULER_ENABLED) != null &&
"true".equalsIgnoreCase(env.getProperty(IS_INCOMING_SCHEDULER_ENABLED).toString())){
boolean status = false;
LOGGER.info("Starting scheduler..... getAllEmails 2");
status = incomingEmailService.getIncomingEmails(2);
LOGGER.info("Completed scheduler..... getAllEmails 2");
return status;
} else {
LOGGER.info("getAllEmails 2 scheduler is disabled");
return false;
}
}
@Scheduled(cron="${mailbox.incoming.scheduler.time3}")
@RequestMapping(value = "/getAllEmails3", method = RequestMethod.GET)
public Boolean getAllEmails3() throws Exception {
if(env.getProperty(IS_INCOMING_SCHEDULER_ENABLED) != null &&
"true".equalsIgnoreCase(env.getProperty(IS_INCOMING_SCHEDULER_ENABLED).toString())){
boolean status = false;
LOGGER.info("Starting scheduler..... getAllEmails 3");
status = incomingEmailService.getIncomingEmails(3);
LOGGER.info("Completed scheduler..... getAllEmails 3");
return status;
} else {
LOGGER.info("getAllEmails 3 scheduler is disabled");
return false;
}
}
@Scheduled(cron="${mailbox.incoming.scheduler.time4}")
@RequestMapping(value = "/getAllEmails4", method = RequestMethod.GET)
public Boolean getAllEmails4() throws Exception {
if(env.getProperty(IS_INCOMING_SCHEDULER_ENABLED) != null &&
"true".equalsIgnoreCase(env.getProperty(IS_INCOMING_SCHEDULER_ENABLED).toString())){
boolean status = false;
LOGGER.info("Starting scheduler..... getAllEmails 4");
status = incomingEmailService.getIncomingEmails(4);
LOGGER.info("Completed scheduler..... getAllEmails 4");
return status;
} else {
LOGGER.info("getAllEmails 4 scheduler is disabled");
return false;
}
}
@Scheduled(cron="${mailbox.incoming.scheduler.time5}")
@RequestMapping(value = "/getAllEmails5", method = RequestMethod.GET)
public Boolean getAllEmails5() throws Exception {
if(env.getProperty(IS_INCOMING_SCHEDULER_ENABLED) != null &&
"true".equalsIgnoreCase(env.getProperty(IS_INCOMING_SCHEDULER_ENABLED).toString())){
boolean status = false;
LOGGER.info("Starting scheduler..... getAllEmails 5");
status = incomingEmailService.getIncomingEmails(5);
LOGGER.info("Completed scheduler..... getAllEmails 5");
return status;
} else {
LOGGER.info("getAllEmails 5 scheduler is disabled");
return false;
}
}
@Scheduled(cron="${mailbox.incoming.scheduler.time6}")
@RequestMapping(value = "/getAllEmails6", method = RequestMethod.GET)
public Boolean getAllEmails6() throws Exception {
if(env.getProperty(IS_INCOMING_SCHEDULER_ENABLED) != null &&
"true".equalsIgnoreCase(env.getProperty(IS_INCOMING_SCHEDULER_ENABLED).toString())){
boolean status = false;
LOGGER.info("Starting scheduler..... getAllEmails 6");
status = incomingEmailService.getIncomingEmails(6);
LOGGER.info("Completed scheduler..... getAllEmails 6");
return status;
} else {
LOGGER.info("getAllEmails 6 scheduler is disabled");
return false;
}
}
@Scheduled(cron="${mailbox.incoming.scheduler.time7}")
@RequestMapping(value = "/getAllEmails7", method = RequestMethod.GET)
public Boolean getAllEmails7() throws Exception {
if(env.getProperty(IS_INCOMING_SCHEDULER_ENABLED) != null &&
"true".equalsIgnoreCase(env.getProperty(IS_INCOMING_SCHEDULER_ENABLED).toString())){
boolean status = false;
LOGGER.info("Starting scheduler..... getAllEmails 7");
status = incomingEmailService.getIncomingEmails(7);
LOGGER.info("Completed scheduler..... getAllEmails 7");
return status;
} else {
LOGGER.info("getAllEmails 7 scheduler is disabled");
return false;
}
}
@Scheduled(cron="${mailbox.incoming.scheduler.time8}")
@RequestMapping(value = "/getAllEmails8", method = RequestMethod.GET)
public Boolean getAllEmails8() throws Exception {
if(env.getProperty(IS_INCOMING_SCHEDULER_ENABLED) != null &&
"true".equalsIgnoreCase(env.getProperty(IS_INCOMING_SCHEDULER_ENABLED).toString())){
boolean status = false;
LOGGER.info("Starting scheduler..... getAllEmails 8");
status = incomingEmailService.getIncomingEmails(8);
LOGGER.info("Completed scheduler..... getAllEmails 8");
return status;
} else {
LOGGER.info("getAllEmails 8 scheduler is disabled");
return false;
}
}
@Scheduled(cron="${mailbox.incoming.scheduler.time9}")
@RequestMapping(value = "/getAllEmails9", method = RequestMethod.GET)
public Boolean getAllEmails9() throws Exception {
if(env.getProperty(IS_INCOMING_SCHEDULER_ENABLED) != null &&
"true".equalsIgnoreCase(env.getProperty(IS_INCOMING_SCHEDULER_ENABLED).toString())){
boolean status = false;
LOGGER.info("Starting scheduler..... getAllEmails 9");
status = incomingEmailService.getIncomingEmails(9);
LOGGER.info("Completed scheduler..... getAllEmails 9");
return status;
} else {
LOGGER.info("getAllEmails 9 scheduler is disabled");
return false;
}
}
@Scheduled(cron="${mailbox.incoming.scheduler.time10}")
@RequestMapping(value = "/getAllEmails10", method = RequestMethod.GET)
public Boolean getAllEmails10() throws Exception {
if(env.getProperty(IS_INCOMING_SCHEDULER_ENABLED) != null &&
"true".equalsIgnoreCase(env.getProperty(IS_INCOMING_SCHEDULER_ENABLED).toString())){
boolean status = false;
LOGGER.info("Starting scheduler..... getAllEmails 10");
status = incomingEmailService.getIncomingEmails(10);
LOGGER.info("Completed scheduler..... getAllEmails 10");
return status;
} else {
LOGGER.info("getAllEmails 10 scheduler is disabled");
return false;
}
}
@Scheduled(cron="${mailbox.incoming.scheduler.time11}")
@RequestMapping(value = "/getAllEmails11", method = RequestMethod.GET)
public Boolean getAllEmails11() throws Exception {
if(env.getProperty(IS_INCOMING_SCHEDULER_ENABLED) != null &&
"true".equalsIgnoreCase(env.getProperty(IS_INCOMING_SCHEDULER_ENABLED).toString())){
boolean status = false;
LOGGER.info("Starting scheduler..... getAllEmails 11");
status = incomingEmailService.getIncomingEmails(11);
LOGGER.info("Completed scheduler..... getAllEmails 11");
return status;
} else {
LOGGER.info("getAllEmails 11 scheduler is disabled");
return false;
}
}
@Scheduled(cron="${mailbox.incoming.scheduler.time12}")
@RequestMapping(value = "/getAllEmails12", method = RequestMethod.GET)
public Boolean getAllEmails12() throws Exception {
if(env.getProperty(IS_INCOMING_SCHEDULER_ENABLED) != null &&
"true".equalsIgnoreCase(env.getProperty(IS_INCOMING_SCHEDULER_ENABLED).toString())){
boolean status = false;
LOGGER.info("Starting scheduler..... getAllEmails 12");
status = incomingEmailService.getIncomingEmails(12);
LOGGER.info("Completed scheduler..... getAllEmails 12");
return status;
} else {
LOGGER.info("getAllEmails 12 scheduler is disabled");
return false;
}
}
@RequestMapping(value="/processEmails",method=RequestMethod.GET)
public String processEmails(){
try{
String status = null;
LOGGER.info("Starting scheduler..... processEmails");
status = incomingEmailService.createWorkItem();
LOGGER.info("Completed scheduler..... processEmails");
return status;
}catch(Exception e){
return "Exception::"+e;
}
}
@RequestMapping(value="/processFiles",method=RequestMethod.GET)
public String processFiles(){
try{
String status = null;
LOGGER.info("Starting scheduler..... processFiles");
status = incomingEmailService.fileAttachment();
LOGGER.info("Completed scheduler..... processFiles");
return status;
}catch(Exception e){
return "Exception::"+e;
}
}
}