Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You could use the Quartz library with the <a href="http://quartz-scheduler.org/api/2.0.0/org/quartz/CronTrigger.html" rel="noreferrer">CronTrigger</a> to execute Jobs at a specific date/time. Have a look at their <a href="http://www.quartz-scheduler.org/documentation/quartz-2.x/tutorials/tutorial-lesson-06" rel="noreferrer">tutorial</a>. Here is an example with a simple scheduler:</p> <pre><code>import java.util.Date import org.quartz.JobBuilder.newJob import org.quartz.SimpleScheduleBuilder.simpleSchedule import org.quartz.TriggerBuilder.newTrigger import org.quartz.impl.StdSchedulerFactory import org.quartz.Job import org.quartz.JobExecutionContext import play.api.Application import play.api.GlobalSettings import play.api.Logger object Global extends GlobalSettings { val scheduler = StdSchedulerFactory.getDefaultScheduler(); override def onStart(app: Application) { Logger.info("Quarz scheduler starting...") scheduler.start(); // define the job and tie it to our HelloJob class val job = newJob(classOf[MyWorker]).withIdentity("job1", "group1").build(); // Trigger the job to run now, and then repeat every 10 seconds val trigger = newTrigger() .withIdentity("trigger1", "group1") .startNow() .withSchedule(simpleSchedule() .withIntervalInSeconds(10) .repeatForever()) .build(); // Tell quartz to schedule the job using our trigger scheduler.scheduleJob(job, trigger); } override def onStop(app: Application) { Logger.info("Quartz scheduler shutdown.") scheduler.shutdown(); } } class MyWorker extends Job { def execute(ctxt: JobExecutionContext) { Logger.debug("Scheduled Job triggered at: " + new Date) } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload