1 / 13

Exploring Quartz Scheduler quartz-scheduler

Exploring Quartz Scheduler http://quartz-scheduler.org. Orlando Java User Group Zemian Deng 2011.04.28. Agenda (1.5 hours). Introduction (5 mins) Scheduling Jobs (20 mins) How job is stored and executed (15 mins) Scheduler Deployment (20 mins) Tips for working with quartz API (5 mins)

camila
Download Presentation

Exploring Quartz Scheduler quartz-scheduler

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Exploring Quartz Schedulerhttp://quartz-scheduler.org Orlando Java User Group Zemian Deng 2011.04.28

  2. Agenda (1.5 hours) • Introduction (5 mins) • Scheduling Jobs (20 mins) • How job is stored and executed (15 mins) • Scheduler Deployment (20 mins) • Tips for working with quartz API (5 mins) • QA session (25 mins)

  3. Introduction: What is Quartz • Fancier java.util.Timer • Unix CRON replacement • Rich and flexible API to the scheduler • Data persistence • Job executions control • Schedulers clustering

  4. Introduction: Quartz 2.0 vs 1.8 • Released in March 2011 • New API • Java DSL for creating jobs • Database schema changes http://quartz-scheduler.org/docs/2.0/newInQuartz2.html

  5. Scheduling One Time Job import org.quartz.JobDetail; import org.quartz.Scheduler; import org.quartz.SimpleTrigger; import org.quartz.impl.StdSchedulerFactory; public class QuartzExample { public static void main(String[] args) throws Exception { Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler(); JobDetail job = new JobDetail("job1", SimpleJob.class); SimpleTrigger trigger = new SimpleTrigger("job1"); scheduler.scheduleJob(job, trigger); scheduler.start(); Thread.sleep(3000L); } }

  6. More Scheduling Job Examples • One time job with startTime • Repeat job now • Repeat job with startTime • Repeat job forever • Cron job

  7. Job Storages • In Memory Job Storage • JDBC Job Storage • JTM JDBC Job Storage • Spring JTM Job Storage

  8. Quartz Scheduler Deployment • Standalone single JVM/Quartz scheduler • Server/Client based via RMI registry • Web Container single JVM/Quartz scheduler • Clustering Quartz scheduler servers

  9. Scheduler Tips #1 • Quartz Cron Expression has 6 fields (down to seconds) + 1 optional year field. • Typical Unix/Linux Cron expression has only 5 fields (down to mins only!)

  10. Scheduler Tips #2 Tired of java.util.Calendar& java.util.Date? Use org.quartz.TriggerUtils or Apache commons-langsDateUtils

  11. Scheduler Tips #3 Spring Quartz Scheduler • You can’t disable auto shutdown! • Usage of dataSource force to use DBTable locks.

  12. Scheduler Tips #4 When using RMI server mode, there is a bug that can crash your scheduler: http://jira.terracotta.org/jira/browse/QTZ-135

  13. Questions?

More Related