Spring Batch学习_TaskletStep

Spring Batch学习_TaskletStep

http://docs.spring.io/spring-batch/trunk/reference/html/configureStep.html#taskletStep

Chunk-oriented processing is not the only way to process in a Step. What if a Step must consist as a simple stored procedure call? You could implement the call as an ItemReader and return null after the procedure finishes, but it is a bit unnatural(不自然的,变态的) since there would need to be a no-op ItemWriter. Spring Batch provides the TaskletStep for this scenario(剧情).


The Tasklet is a simple interface that has one method, execute(), which will be a called repeatedly by the TaskletStep until it either returns RepeatStatus.FINISHED or throws an exception to signal a failure.Each call to the Tasklet is wrapped in a transaction. Tasklet implementors might call a stored procedure, a script, or a simple SQL update statement. To create a TaskletStep, the 'ref' attribute of the <tasklet/> element should reference a bean defining a Tasklet object; no <chunk/> element should be used within the <tasklet/>:

<step id="step1">
    <tasklet ref="myTasklet"/>
</step>

<job id="taskletJob">
	<step id="deleteFilesInDir">
		<tasklet ref="fileDeletingTasklet" />
	</step>
</job>

====END====

你可能感兴趣的:(Spring Batch学习_TaskletStep)