Java J2EE Portal
Enterprise Java Station
J2EE curve
Java News / Articles
Java News / Articles
JavaOne Update - JavaFX, Java On Linux & Oracle JSF
Effectively Taming Service Oriented Architecture (SOA) Chaos
Security Assertion Image
Security Assertion Markup Language (SAML)
Processing...
Buy Java, Deals On Software Technology Store
Click here for great deals on computers, laptops, software and books
Task Scheduling with Quartz - Integration with OSWorkflow PDF Print
Written by Content Team   
Sep 24, 2007 at 12:47 AM
Quartz is a popular open source job scheduling system that can be integrated with any Java application. In this excerpt from the new book OSWorkflow: A guide for Java developers and architects to integrating open-source Business Process Management published by Packt, author Diego Adrian Naya Lazo explores the Quartz task scheduler and its integration with OSWorkflow. He also gives a tutorial on Quartz sending events and actions to OSWorkflow.

Both people-oriented and system-oriented BPM systems need a mechanism to execute tasks within an event or temporal constraint, for example, every time a state change occurs or every two weeks. BPM suites address these requirements with a job-scheduling component responsible for executing tasks at a given time.
OSWorkflow, the core of our open-source BPM solution, doesn't include these temporal capabilities by default. Thus, we can enhance OSWorkflow by adding the features present in the Quartz open-source project.

What is Quartz?

Quartz is a Java job-scheduling system capable of scheduling and executing jobs in a very flexible manner. The latest stable Quartz version is 1.6. You can download Quartz from http://www.opensymphony.com/quartz/download.action.

Installing

The only file you need in order to use Quartz out of the box is quartz.jar. It contains everything you need for basic usage. Quartz configuration is in the quartz.properties file, which you must put in your application's classpath.

Basic Concepts

The Quartz API is very simple and easy to use. The first concept that you need to be familiar with is the scheduler. The scheduler is the most important part of Quartz, managing as the word implies the scheduling and unscheduling of jobs and the firing of triggers.
A job is a Java class containing the task to be executed and the trigger is the temporal specification of when to execute the job. A job is associated with one or more triggers and when a trigger fires, it executes all its related jobs. That's all you need to know to execute our Hello World job.

Integration with OSWorkflow

By complementing the features of OSWorkflow with the temporal capabilities of Quartz, our open-source BPM solution greatly enhances its usefulness. The
Quartz-OSWorkflow integration can be done in two ways—Quartz calling OSWorkflow workflow instances and OSWorkflow scheduling and unscheduling Quartz jobs. We will cover the former first, by using trigger-functions, and the latter with the ScheduleJob function provider.

Creating a Custom Job

Job's are built by implementing the org.quartz.Job interface as follows:

void execute(JobExecutionContext context) throws
JobExecutionException;

The interface is very simple and concise, with just one method to be implemented. The Scheduler will invoke the execute method when the trigger associated with the job fires. The JobExecutionContext object passed as an argument has all the context and environment data for the job, such as the JobDataMap.
The JobDataMap is very similar to a Java map but provides strongly typed put and get methods. This JobDataMap is set in the JobDetail file before scheduling the job and can be retrieved later during the execution of the job via the JobExecutionContext's getJobDetail().getJobDataMap() method.

Page 1 of 9



Add This Feed Button

Enter your Email

IndicThreads.com Conference On Java Technology, Pune, India
Java Expert Interviews
TedLeungOpenSource
Why is open source so successful? Why should I contribute to open source?
RichUngerNetBeans
NetBeans was the early bird but has Eclipse caught the worm?
JonathanAgileXPSoftwareTestingX
The good and bad of XP and Agile notions of software testing
Processing...
Go to top of page  Home |
SiteMap

Copyright 2004 to 2008 Rightrix Solutions. All rights reserved. All product names are trademarks of their respective companies. Java and all Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries. Rightrix Solutions and IndicThreads.com are independent of Sun Microsystems, Inc.

Views expressed at IndicThreads.com reflect the views of the authors alone, and do not necessarily reflect those of IndicThreads.com. IndicThreads.com and it's authors are not responsible for reader comments and opinions.

Enterprise Java J2EE JEE Portal >> IndicThreads.com