0

I'm a little bit confused!

Spring Batch provides two different ways for implementing a job: using tasklets and chunks.

So, when I have this:

<tasklet>
  <chunk 
    reader = 'itemReader'
    processor = 'itemProcessor'
    writer = 'itemWriter'
    />
</tasklet>

What kind of implementation is this? Tasklet? Chunk?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Teymo
  • 11
  • 1
  • 3

1 Answers1

0

That's a chunk type step, because inside the <tasklet> element is a <chunk> element that defines a reader, writer, and/or processor.

Below is an example of a job executing first a chunk and second a tasklet step:

<job id="readMultiFileJob" xmlns="http://www.springframework.org/schema/batch">
  <step id="step1" next="deleteDir">
    <tasklet>
      <chunk reader="multiResourceReader" writer="flatFileItemWriter"
        commit-interval="1" />
    </tasklet>
  </step>
  <step id="deleteDir">
    <tasklet ref="fileDeletingTasklet" />
  </step>
</job>

<bean id="fileDeletingTasklet" class="com.mkyong.tasklet.FileDeletingTasklet" >
  <property name="directory" value="file:csv/inputs/" />
</bean>

<bean id="multiResourceReader"
class=" org.springframework.batch.item.file.MultiResourceItemReader">
  <property name="resources" value="file:csv/inputs/domain-*.csv" />
  <property name="delegate" ref="flatFileItemReader" />
</bean>

Thus you can see that the distinction is actually on the level of steps, not for the entire job.

Stefan Reisner
  • 607
  • 5
  • 12