I am working on writing a Job when my application is deployed. This Job should run every 5 mins and it should start immediately. But the problem is it is starting 5 mins after the deployment and repeating for every five minutes. Please help me with the changes required to start it immediately when the application is deployed.
public void contextInitialized(ServletContextEvent servletContextEvent) {
logger.info("contextInitialized() ,Starting instantiating Processor Engine");
try{
JobDetail job = newJob(MyServiceProcessor.class).withIdentity(
"CronQuartzJob", "Group").build();
Trigger trigger = newTrigger().withIdentity("TriggerName", "Group").withSchedule(CronScheduleBuilder.cronSchedule("0 0/5 * * * ?")).build();
scheduler = new StdSchedulerFactory().getScheduler();
scheduler.start();
scheduler.scheduleJob(job, trigger);
}
catch (SchedulerException e) {
logger.error(", contextInitialized() ,Problem in starting Processor Engine"+e);
}