Skip to content

Quartz_integration

stockiNail edited this page Oct 12, 2015 · 3 revisions

What's Quartz

(quoted from Quartz site)

Quartz is a richly featured, open source job scheduling library that can be integrated within virtually any Java 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 that may execute virtually anything you may program them to do.

Quartz meets JEM

The integration between Quartz and JEM has been realized implementing Quartz jobs which are wrappers of "submit" commands of JEM.

There are 3 Quartz jobs implementation and these jobs are using the 3 possible methods to submit jobs in JEM, as following:

  • JobLocalHostSubmit: it can use LocalHostSubmit of JEM which can submit jobs from the same server of a JEM node
  • JobSubmit: it can use Submit of JEM which can submit jobs from whatever server which can access to JEM cluster. This should be the most important submitter.
  • JobHttpSubmit: it can use HttpSubmit of JEM which can submit jobs from whatever server by HTTP protocol.

JobDetail preparation

Let's see how to build a Quartz JobDetail, ready to be scheduled, for all 3 Quartz jobs. For all parameters of JEM submit commands, please see here.

JobLocalHostSubmit

JobDetail jobLocalHostSubmit = JobBuilder.newJob(JobLocalHostSubmit.class)
                                                               .withIdentity("job1", "group1")
                                                               .usingJobData("jemEnv", "TEST-Env")
                                                               .usingJobData("jclUrl", "file:/home/jem/workspace/TestOOM/ECHO.xml")
                                                               .usingJobData("jemPort", "5710")
                                                               .usingJobData("password", "jem_password")
                                                               .usingJobData("jclType", "ant")
                                                               .build();

The parameters are the following meaning:

  • jemEnv is the JEM environment, where submit the job
  • jclUrl is the URL representing JCL to submit
  • jemPort is the port used by JEM node
  • password is the password used to access to JEM cluster
  • jclType is the JCL type, i.e ant for Apache ANT or sb for SpringBatch

JobSubmit

JobDetail jobSubmit = JobBuilder.newJob(JobSubmit.class).withIdentity("job2", "group2")
                                                        .usingJobData("jclUrl", "file:/home/jem/workspace/TestOOM/ECHO.xml")
                                                        .usingJobData("jclType", "ant")
                                                        .usingJobData("password", "jem_password")
                                                        .usingJobData("hostForJemWeb", "http://192.10.10.10:8080/jem")
                                                        .build();

The parameters are the following meaning:

  • jclUrl is the URL representing JCL to submit
  • hostForJemWeb is the http address where JEM web application context has been deployed
  • password is the password used to access to JEM cluster
  • jclType is the JCL type, i.e ant for Apache ANT or sb for SpringBatch

JobHttpSubmit

 JobDetail jobHttpSubmit = JobBuilder.newJob(JobHttpSubmit.class).withIdentity("job3", "group3")
                                                                 .usingJobData("jclUrl", "file:/home/jem/workspace/TestOOM/ECHO.xml")
                                                                 .usingJobData("jclType", "ant")
                                                                 .usingJobData("hostForJemWeb", "http://192.10.10.10:8080/jem")
                                                                 .usingJobData("user", "root")
                                                                 .usingJobData("password", "a")
                                                                 .build();

The parameters are the following meaning:

  • jclUrl is the URL representing JCL to submit
  • hostForJemWeb is the http address where JEM web application context has been deployed
  • user is the user id used to access to JEM web application
  • password is the password used to access to JEM web application
  • jclType is the JCL type, i.e ant for Apache ANT or sb for SpringBatch

Execution code

All Quartz jobs, described above, will throw a JobExecutionException when the return code of JEM job ends in a return code not equals to 0.

Clone this wiki locally