java - Execute jobs after JVM termination -
is possible schedule jobs inside jvm execution after jvm has been terminated?
in application, user can opt receive notifications on new emails in inbox. accomplished using quartz, emailchecker
job scheduled execute every 45 seconds.
public void checkinbox() throws schedulerexception { jobdetail job = jobbuilder.newjob(emailchecker.class) .withidentity("emailjob", "jobgroup").build(); trigger trigger = triggerbuilder.newtrigger() .withidentity("emailtrigger", "jobgroup") .withschedule(cronschedulebuilder.cronschedule("0/45 * * * * ?")) .build(); scheduler scheduler = new stdschedulerfactory().getscheduler(); scheduler.start(); scheduler.schedulejob(job, trigger); }
this works fine, while jvm running. once exits, no more notifications sent.
the application desktop app, , therefore not running time. , feature majorly useless if worked inside jvm since user able view inbox in real time, notifications redundant.
not internally jvm, because once jvm terminates isn't running execute jobs. use tool cron or at schedule new jvm. if can leave jvm executing, can use jvm schedule jobs (you possibly use quartz-scheduler).
Comments
Post a Comment