Java EE 7 SDK |
This sample demonstrates how to use the javax.batch.operations.JobOperator
interface to submit batch jobs.
This sample application demonstrates how to use the Batch Processing API (JSR 352)
to submit batch jobs and how to obtain information about submitted jobs using the
JobOperator
interface. This sample also demostrates how to perform
batch processing using multiple partitioned chunks.
The PayrollPartitionMapper creates 5 partitions to process 30 payroll records. Each Partition is run on a separate thread by the Batch runtime, but each Partition runs the same Chunk (meaning same ItemReader, same ItemWriter and same ItemProcessor). In order to let each Partition to work on different payroll records, the PayrollPartitionMapper sets the starting and ending employee numbers that each Partitioned step must process.
In this sample, the SimpleItemReader reads PayrollInputRecord(s) from a Singleton bean.
In this sample, SimpleItemProcessor receives PayrollInputRecord (from the batch runtime), computes the net pay and returns a PayrollRecord (to the batch runtime). The batch runtime then calls ItemWriter
In this sample, SimpleItemWriter stores the processed PayrollRecord into an EJB Singleton bean.
The sample uses the embedded JavaDB database service included with the Glassfish server.
The sample is built and deployed as a WAR file.
This sample application demonstrates the following key features:
JobOperator.start()
to submit a batch job. This method returns the execution id for the job executionJobOperator.getJobInstances()
method to obtain all JobInstabnces for the "payroll" jobjobOperator.getJobInstances()
to get a list of job instances submitted by this application.jobOperator.getJobExecutions(jobInstance)
to get a list of JobExecution
objects.JobExecution
objects:JobExecution.getJobName()
to get the job name.JobExecution.getBatchStatus()
to get the batch status of the job execution.JobExecution.getExitStatus()
to get the exit status of the job execution.JobExecution.getStartTime()
to obtain the time when the job execution started.JobExecution.getEndTime()
to obtain the time when the job execution completed.Perform the following steps to build, deploy, and run the application:
samples_install_dir
is the sample application base directory. Go to: samples_install_dir/javaee7/batch/joboperator-api
.
mvn package
command from a command line terminal.asadmin deploy --force target/partition.war
command from a command line terminal.mvn clean
command from a command line terminal to clean up the target directory.asadmin undeploy partition
command from a command line terminal.If you have problems when running the application, refer to the troubleshooting document.
Copyright © 1997-2013 Oracle and/or its affiliates. All rights reserved.