May 20th, 2009, 08:09 PM
Starting or Stopping Spring Batch Jobs - Programmatically
i am using Quartz 1.6.4 as the scheduler for Spring Batch 1.1.4 jobs in an enterprise web application, which uses struts + spring (including spring batch) + quartz. This web application allows users to "reschedule" (via cron expression) jobs (persisted in quartz jdbc job store) and to start/stop jobs based on business requirements.
A single quartz job is used to start the spring batch jobs based on its schedule with the web applciation running. Whenever there are batch jobs running, users of the web application can "stop" or "start" batch jobs that are running.
i've researched that it is currently not possible for an enterprise scheduler e.g. Quartz, to interact with the batch launcher to start/stop a batch job. Further, the interface JobOperator is not available in Spring Batch 1.1.4 to start/stop the batch jobs programmatically.
I've tried to 1) to start/stop by using the JobExecution runtime instance, which is failing, as the JobExecution is always null (?), unless the job is completed. 2) Besides using the JobExecution, i've also tried to delete/change (job status) jobs instance/excution related records in the database (job repository) but to no avail.
How can spring batch jobs be started/stopped programmatically?
Thanks in advance. Your help is much appreciated.