Java Reference
In-Depth Information
boolean stop( long executionId )
Sends a stop signal to the JobExecution
identified. It's important to note that this
doesn't mean the job has stopped, only that the
request to stop has been made.
Up to now this topic has been using a basic java command line command to launch Spring Batch's
CommandLineJobRunner to run jobs. To see the JobOperator in action, you create a JMX JobRunner that
allows you to execute a job via a JMX console. To get started, you have to write a main method that keeps
the Spring application running without actually doing anything. Listing 5-11 shows how you do that.
Listing 5-11. Bootstrapping a Spring Application
package com.apress.springbatch.chapter5;
import org.springframework.context.ApplicationContext;
public class Batch {
public static void main(String[] args) {
try {
ApplicationContext context =
new ClassPathXmlApplicationContext("launch-context.xml");
Object lock = new Object();
synchronized (lock) {
} catch (Exception e) {
When you have the code written to launch your Spring application and keep it running, you can
write JMXJobRunner . To do this, all you do is write a POJO that starts a job based on the job name passed
in. As you can see in Listing 5-12, the code to accomplish this isn't much more than a wrapper around a
JobOperator instance.
Listing 5-12. JMXJobRunner
package com.apress.springbatch.chapter5;
import org.springframework.batch.core.JobParametersInvalidException;
import org.springframework.batch.core.launch.JobInstanceAlreadyExistsException;
import org.springframework.batch.core.launch.JobOperator;
import org.springframework.batch.core.launch.NoSuchJobException;
Search WWH ::

Custom Search