Quartz is a full-featured, open source job scheduling system that can be integrated with, or used along side virtually any J2EE or J2SE application - from the smallest stand-alone application to the largest e-commerce system. Quartz can be used to create simple or complex schedules for executing tens, hundreds, or even tens-of-thousands of jobs; jobs whose tasks are defined as standard Java components or EJBs. The Quartz Scheduler
includes many enterprise-class features, such as JTA transactions and clustering.
 | Quartz already integrated in Sakai 2.3 or later
The Quartz job scheduler, it's already integrated into Sakai in recent versions. You don't need to do anything special to set it up. |
Quartz Scheduler Tool Installation
James Watkin, September 29, 2005
This is how we got the Quartz Scheduler Sakai Tool to work at UCLA under Sakai 2.0.1. I don't know if this is the best way to install it, so please correct me where I'm wrong.
Preconditions:
Sakai 2.0.1 is already installed.
Sakai 2.0.0 as well as 2.0.1 dependencies are in the .maven/repository.
Download/install Sakai Maven plug-in:
1. Go to maven-1.0.2 directory.
2. Issue this command:
(Use version 2.0.0 because the Scheduler tool seems to need it. I tried using the plugin version set to 2.0.1 and changing the Scheduler's project.xml files' currentVersion to 2.0.1, but that method didn't work. I'd get a blank Scheduler pane and some JSF related errors.)
Get the latest Quartz Scheduler Source, as part of the latest Sakai (on Windows):
1. Install TortoiseSVN.
2. Right-click in target directory, from the pop-up menu select TortoiseSVN export.
3. In the "URL of repository" field, enter: https://source.sakaiproject.org/svn/sakai/trunk/
4. Choose HEAD Revision.
5. Click "OK".
Don't configure the quartz.properties file:
With the version of the scheduler source that we have, my understanding is that the
sakai-src/scheduler/scheduler-component-shared/src/java/org/sakaiproject/component/app/scheduler/quartz.properties file isn't
actually getting used. The quartz.properties dataSource properties are replaced by values derived from Spring injection using
<property name="dataSource">
<ref bean="javax.sql.DataSource"/>
</property>
I believe this dataSource comes from the various @javax.sql.BaseDataSource properties in your sakai.properties file. The org.quartz.jobStore.driverDelegateClass property is looking to sqlService.getVendor() as a flag for its settings. I believe this value comes from your vendor@org.sakaiproject.service.framework.sql.SqlService property in your sakai.properties file.
Add the Quartz tables to MySQL:
1. Copy the scheduler/ddl/tables_mysql_innodb.sql file into mysql/bin.
2. From the mysql/bin directory, issue this command: mysql -u root -p
3. Enter the root password.
4. From the mysql command prompt, issue these commands (assumes your database name and user account name is sakai):
You're putting the Quartz tables in your sakai database since the scheduler tool will end up with the general sakai dataSource configured within sakai.properties.
Deploy the Scheduler module:
1. Copy the scheduler directory (from the root of the Sakai HEAD src exported in the steps above) into the 2.0.1 release version of the source at its root level. I don't know if this is absolutely necessary, but it's a good place for it.
2. Each of the 5 project.xml files within the Scheduler folder will have their currentVersion set at 2.0.0. Leave it this way.
3. Navigate to the scheduler directory you just placed in the Sakai 2.0.1 tree.
4. From the scheduler directory, issue this maven command:
Add Quartz to your UI:
1. Login to the sakai portal as admin.
2. Go to the Administration Workspace.
3. Click on the "Sites" tool (in the left nav).
4. Click on the !admin Site ID.
5. Scroll down and click on the Pages button (under Continue Editing).
6. At the top of the pane, click on "New Page".
7. Enter a Title: Quartz Scheduler.
8. Click on the "Tools" button (under Continue Editing).
9. At the top of the pane, click on "New Tool".
10. Select the "Job Scheduler Based On Quartz (sakai.scheduler)" feature.
11. Scroll down, click on the "Save" button (under Complete the Site Edit).
12. Leave the "Sites" tool.
13. The Scheduler tool will appear in your tool list (left nav).
Configure a Quartz job:
1. Click on the Quartz Scheduler tool (in the left nav tool list).
2. Click on Jobs (at the top of the pane).
3. Click on New Job.
4. Enter a Job Name.
5. Select a job from the pop up list.
6. Click the "Post" button.
7. In the new job listing, click on the Triggers link.
8. Click on "New Trigger".
9. Create a Trigger Name.
10. Create a Cron Expression. Click the "help" link next to this field for cron expression information. (This "0 0 0/1 * * ?" means fire every hour.)
11. Click on "Post".
12. Click on "Event Log" to watch for your jobs to fire.
(The supplied test jobs write execute or execute2 to standard out.)
To create custom jobs:
1. Use the sample job classes as examples. They're in scheduler/scheduler-component-shared/src/java/org/sakaiproject/component/app/scheduler/jobs.
2. After creating your job class, edit the scheduler/scheduler-component/src/webapp/WEB-INF/components.xml file and add your job class value element.
Examples:
<property name="qrtzJobs">
<set>
<value>org.sakaiproject.component.app.scheduler.jobs.NoRelatedClassTestJob</value>
<value>org.sakaiproject.component.app.scheduler.jobs.TestJob</value>
<value>org.sakaiproject.component.app.scheduler.jobs.TestJob2</value>
</set>
</property>
3. Redeploy the Scheduler tool.
 | Contact Information
James Watkin
ACIS Software Development
UCLA Anderson School
james.watkin@anderson.ucla.edu
Voice: 1-310-825-5030
Fax: 1-310-825-4835 |
Andrew Poland's Explanation
A quartz job is just a class that implements the Job interface. It needs only one method, execute:
package org.quartz;
public interface Job {
public void execute(JobExecutionContext context)
throws JobExecutionException;
}
Once you create your job, you just need to deploy it within the classpath and add it to components.xml so that quartz will recognize it. Then you'll be able to schedule it to run whenever you like via the Job Scheduler UI.
https://source.sakaiproject.org/svn/jobscheduler/trunk/scheduler-
component/src/webapp/WEB-INF/components.xml
<property name="qrtzJobs">
<set>
<value>org.sakaiproject.component.app.scheduler.jobs.TestJob</value>
<value>org.sakaiproject.component.app.scheduler.jobs.TestJob2</value>
<value>org.sakaiproject.component.app.scheduler.jobs.LongTestJob</value>
</set>
</property>
Oncourse uses many quartz jobs, feel free to use them as examples:
https://source.sakaiproject.org/svn/oncourse/trunk/src/jobscheduler/scheduler-component-shared/src/java/org/sakaiproject/component/app/scheduler/jobs/
Also opensymphony has a tutorial on quartz:
http://www.opensymphony.com/quartz/wikidocs/Tutorial.html
Some notes -