How to Create a Chunk-Oriented Batch with the Java Batch API

import static java.lang.System.out;

import javax.batch.runtime.BatchRuntime;
import javax.batch.operations.JobOperator;

public final class BatchSample {

  public static void main(final String[] args) throws Exception {
    final JobOperator jobOperator = BatchRuntime.getJobOperator();

    out.println(jobOperator.start("samplejob", null));


import javax.batch.api.AbstractItemReader;

public final class SampleItemReader extends AbstractItemReader {

  public Object readItem() {
    return null;


import javax.batch.api.ItemProcessor;

public final class SampleItemProcessor implements ItemProcessor {

  public Object processItem(final Object item) {
    return null;


import javax.batch.api.AbstractItemWriter;

import java.util.List;

public final class SampleItemWriter extends AbstractItemWriter {

  public void writeItems(final List items) {



<?xml version="1.0" encoding="UTF-8"?>
<job xmlns="" id="samplejob">
  <step id="step1">
      <reader ref="sampleItemReader" />
      <processor ref="sampleItemProcessor" /> <!-- optional -->
      <writer ref="sampleItemWriter" />
    <next on="COMPLETED" to="step2" /> <!-- go the "step2" if the exit status is "COMPLETED" -->
  <step id="step2">


<?xml version="1.0" encoding="UTF-8"?>
<batch-artifacts xmlns="">
  <ref id="sampleItemReader" class="SampleItemReader" />
  <ref id="sampleItemProcessor" class="SampleItemProcessor" />
  <ref id="sampleItemWriter" class="SampleItemWriter" />

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s