The term enterprise is used so oftenand so carelesslytoday that it's hard to know which definition is being referred to. We have one meaning in mind when we use it in this book: the software systems and processes that are part of an organization. These systems might be legacy mainframes, a client/server architecture, or J2EE applicationsit doesn't matter. Realworld examples of where job schedulers can be used are plentiful. The following scenarios, although obviously not exhaustive, present some common uses in applications today.
Scenario #1: Sending E-Mails, Reminders, and Alerts
Many web sites (both commercial and otherwise) allow users to register an account that includes a username and password. For security reasons, it's a good idea to expire the user's passwords regularlysay, every 90 days. You might create a job that runs every night at midnight and sends an e-mail to a list of users when their passwords will expire in three days. This is great use of a job scheduler. Figure 1.2 illustrates the password reminder job.
Figure 1.2. The password expiration job sends e-mails nightly to remind users that their passwords will expire soon.
Besides expiring passwords, Web sites can send other alerts and reminders(not to mention spam). A job scheduler can be used for those in a similar way.
Scenario #2: Performing File-Transfer Operations
Many businesses need to integrate information with their vendors and clients. One method of performing this integration is to exchange data files. Businesses can use real-time methods such as SOAP, but many don't need to operate in real time and instead choose asynchronous methods such as File Transfer Protocol (ftp) to drop and pick up files.
Picture a worker's compensation company that receives files every morning containing patient/accident information. This company could hire someone to manually check the ftp site every morning for the file. Alternatively, someone could write a job that executes every morning to scan the ftp site and insert the files into the patient database. With a scheduled job, the employee no longer has to perform the manual checks and can do something more valuable for the company. Figure 1.3 illustrates the file-transfer operation.
Figure 1.3. The filetransfer job checks the ftp site for patient files to process to the database.
Scenario #3: Creating Sales Reports
Companies are driven on profit and loss, and it's important to have the latest revenue and margin data for executives and the finance team to analyze. Pulling the data for sales reports can be very slow and resource intensive because it usually involves searching thousands of records and joining many database tables. A better approach involves running a job every night after the billing and invoicing is updated to create temporary tables or views that then can be used to run reports against. Creating temp tables or views makes the reports more dynamic, and users won't get frustrated while waiting for a report to generate. Some reporting packages, such as Crystal Reports XI, include a job scheduler (see Figure 1.4).
Figure 1.4. The sales data report is executed to generate revenue and margin information for the sales team.
Scheduling in the Enterprise
Getting Started with Quartz
Cron Triggers and More
JobStores and Persistence
Implementing Quartz Listeners
Using Quartz Plug-Ins
Using Quartz Remotely
Using Quartz with J2EE
Quartz and Web Applications
Using Quartz with Workflow
Appendix A. Quartz Configuration Reference