[英]Spring Batch: is this a tasklet or chunk?
I'm a little bit confused!我有点困惑!
Spring Batch provides two different ways for implementing a job: using tasklets and chunks. Spring Batch 提供了两种不同的方式来实现作业:使用小任务和块。
So, when I have this:所以,当我有这个时:
<tasklet>
<chunk
reader = 'itemReader'
processor = 'itemProcessor'
writer = 'itemWriter'
/>
</tasklet>
What kind of implementation is this?这是一个什么样的实现? Tasklet?小任务? Chunk?块?
That's a chunk type step, because inside the <tasklet>
element is a <chunk>
element that defines a reader, writer, and/or processor.这是一个块类型的步骤,因为在<tasklet>
元素内部是一个<chunk>
元素,它定义了读取器、写入器和/或处理器。
Below is an example of a job executing first a chunk and second a tasklet step:下面是一个作业的示例,该作业首先执行一个块,然后执行一个 tasklet 步骤:
<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.因此,您可以看到区别实际上是在步骤级别上,而不是整个工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.