Quartz
Quartz Framework. Reminder 구현을 위해서 참고하는 framework.
Quartz Tutorial
Reference
Initializing a scheduler within a servlet container
web.xml
<web-app xmlns="...">
...
<servlet>
<servlet-name>QuartzInitializer</servlet-name>
<servlet-class>org.quartz.ee.servlet.QuartzInitializerServlet</servlet-class>
<init-param>
<param-name>shutdown-on-unload</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
...
</web-app>
JDBC Job Store
- "docs/dbTables" 하부에 있는 sql 을 실행시켜서 테이블을 생성한다.
quartz.properties 설정
-
To use JDBCJobStore (and assuming you're using StdSchedulerFactory) you first need to set the JobStore class property of your Quartz configuration to be either org.quartz.impl.jdbcjobstore.JobStoreTX or org.quartz.impl.jdbcjobstore.JobStoreCMT - depending on the selection you made based on the explanations in the above few paragraphs.
Configuring Quartz to use JobStoreTx
org.quartz.jobStore.class = org.quartz.impl.jdbcjobstore.JobStoreTX
-
The DriverDelegate is responsible for doing any JDBC work that may be needed for your specific database. StdJDBCDelegate is a delegate that uses "vanilla" JDBC code (and SQL statements) to do its work. If there isn't another delegate made specifically for your database, try using this delgate - we've only made database-specific delegates for databases that we've found problems using StdJDBCDelegate with (which seems to be most . Other delegates can be found in the "org.quartz.impl.jdbcjobstore" package, or in its sub-packages. Other delegates include DB2v6Delegate (for DB2 version 6 and earlier), HSQLDBDelegate (for HSQLDB), MSSQLDelegate (for microsoft SQLServer 2000), PostgreSQLDelegate (for PostgreSQL 7.x), WeblogicDelegate (for using JDBC drivers made by Weblogic), and OracleDelegate (for using Oracle 8i and 9i).
Configuring JDBCJobStore to use a DriverDelegate
org.quartz.jobStore.driverDelegateClass = org.quartz.impl.jdbcjobstore.StdJDBCDelegate
- 테이블 prefix 바꾸기
Configuring JDBCJobStore with the Table Prefix
org.quartz.jobStore.tablePrefix = QRTZ_
- Datasource name
Configuring JDBCJobStore with the name of the DataSource to use
org.quartz.jobStore.dataSource = myDS
JobDataMap
-
The JobDataMap can be used to hold any number of (serializable) objects which you wish to have made available to the job instance when it executes. JobDataMap is an implementation of the Java Map interface, and has some added convenience methods for storing and retreiving data of primitive types.
-
이걸 사용해서 JobDetail 정보에 Schedule 정보를 넣어두고 Job 이 실행될 때 사용하면 된다.
-
Job이 실행될때 방식을 어떤식으로 하는지에 대한 패턴이 필요하다. 예: JobExecuteNotify / JobExecuteGWMail / JobExecuteSMS 등등등 ==> JobListener 가 이미 존재한다. 이것을 확장하면 되겠다. 좀더 알아보자.
JobListener
Lesson 7: TriggerListeners and JobListeners : org.quartz.TriggerListener and/or org.quartz.JobListener interface 를 구현하면 된다.
- Using Your Own Listeners
Adding a JobListener to the Scheduler
scheduler.addGlobalJobListener(myJobListener);
or
scheduler.addJobListener(myJobListener);
Quartz 를 사용하기 위해서 결정해야하는 주요 요소들
The major components that need to be configured before Quartz can do its work are:
-
DataSources (if necessary)
- The Scheduler itself
Clustering
- Clustering currently only works with the JDBC-Jobstore (JobStoreTX or JobStoreCMT).
- Enable clustering by setting the "org.quartz.jobStore.isClustered" property to "true".
-
Never run clustering on separate machines, unless their clocks are synchronized using some form of time-sync service (daemon) that runs very regularly (the clocks must be within a second of each other). See http://www.boulder.nist.gov/timefreq/service/its.htm if you are unfamiliar with how to do this. -
Never fire-up a non-clustered instance against the same set of tables that any other instance is running against. You may get serious data corruption, and will definitely experience eratic behavior.
History
Last edited on 03/28/2007 18:43 by JasonPA
Comments (0)