Email notifications and reminders in Java web application using Quartz Scheduler

I want to create a simple Java web application to send email notifications after a task, such as a request submitted for approval, and reminders (approve claims) at regular intervals. I want to do this using Quartz Scheduler. I'm a newbie, so anyone can help me get started with this.

Thanks at Advance.

I copy and paste the JAR file: quartz-1.8.0 in WEB-INF \ lib and even in the general \ lib, then it was not found when importing into a Java file. :(

+3
source share
1 answer

Create a servlet that starts with the init web application.

<web-app>
    ...
    <servlet>
     <servlet-name>Emailer</servlet-name>
     <servlet-class>my.servlet.Emailer</servlet-class>
     <load-on-startup>1</load-on-startup>
    </servlet>
    ...
</web-app>

init() ( 10 )

SchedulerFactory schFact = new org.quartz.impl.StdSchedulerFactory();
Scheduler sched = schFact.getScheduler();
JobDetail job = new JobDetail("job1", "group1", EmailerJob.class);
CronTrigger trigger = new CronTrigger("trigger1", "group1", "job1", "group1", "* 0/10 * * * ?");
sched.addJob(job, true);
sched.start();

, Quartz.

EmailerJob implement Job{
        public void execute(JobExecutionContext arg0) throws JobExecutionException {
        //Code to send mails goes here
    }

}

P.S. , , .

@jmort253 , Quartz - , , , - .


, Google . , ! Java - - API

# 1 ContextListener .


1

@jhouse , , Job, , SendMailJob Quartz . @jhouse.

+7

Source: https://habr.com/ru/post/1790150/


All Articles